Retrieving Deformed Splines

  • Hello,

    I'm trying to get access to the result of a spline that has been deformed by a Bend. I've attached a scene file with a cloner mimicking the behavior I want to achieve, but I haven't been able to do it yet.

    Using GetCache().GetDeformCache() isn't returning just the four points of the circle and I'm not sure another way to get a deformed spline. This seems like it would be rather simple but I'm not sure where to proceed.

    Deformed Circle.c4d


  • Hi Johan, thanks for reaching out us.

    With regard to your request, I warmly suggest to have a look at:

    A first attempt to make it work should look like this:

    import c4d
    def DoRecursion(op, index):
        tp = op.GetDeformCache()
        if tp is not None:
            DoRecursion(tp, index)
            tp = op.GetCache()
            if tp is not None:
                DoRecursion(tp, index)
                if not op.GetBit(c4d.BIT_CONTROLOBJECT):
                    if op.IsInstanceOf(c4d.Opoint):
                        for i in index:
                            print "\t\t", op.GetAllPoints()[i]
        tp = op.GetDown()
        while tp is not None:
            DoRecursion(tp, index)
            tp = tp.GetNext()
    # Main function
    def main():
        # get the real spline representation
        realSpline = op.GetRealSpline()
        if realSpline is None:
        # allocate a SplineHelp instance and init it with the real spline
        splineH = c4d.utils.SplineHelp()
        # get the spline points and store its length
        splinePnts = realSpline.GetAllPoints()
        splinePntsCnt = len(splinePnts)
        # allocate a list to store the correspondance between the spline points and the one belonging to its line representation
        pntIndxInLine = []
        for i in xrange(splinePntsCnt):
            pntIndxInLine.append(splineH.GetPointIndex(i, 0)/splinePntsCnt)
        # recurse over the geometry to look for its cache
        DoRecursion(op, pntIndxInLine)
        # free the SplineHelp instance
    # Execute main()
    if __name__=='__main__':

    Best, Riccardo

  • Thanks for the reply, it really helped me out.


Log in to reply