Duplicate of Destination X Rail spline of a MoSpli



  • On 26/08/2015 at 11:18, xxxxxxxx wrote:

    Hi,

    As an exercise I am trying to duplicate the Destination X Rail spline of a MoSpline, after changing its width.

    So far I wasn't able to create a duplicate of the spline with the new offset/width, I just get the original one as if it is ignoring it is being modified by the MoSpline.

    Any ideas with way to go? I was looking into GetCache(), but I wanted to ask first in case is something way more simpler.

    Thanks in advance!

    import c4d
    from c4d import gui
    #Welcome to the world of Python

    def main() :

    #Create clone of original Spline
        oSp = op.GetClone()
        oSp.SetName("original")
    #Create 2nd Spline
        sSp = oSp.GetClone()
        sSp.SetName("rail X")
    #Create MoSpline
        mS = c4d.BaseObject(440000054)

    #Assign splines and width
        mS[c4d.MGMOSPLINEOBJECT_MODE] = 1
        mS[c4d.MGMOSPLINEOBJECT_SOURCE_SPLINE] = oSp
        mS[c4d.MGMOSPLINEOBJECT_DEST_RAILX] = sSp
        mS[c4d.MGMOSPLINEOBJECT_SPLINE_WIDTH] = 100
        
    #Add to Scene
        doc.InsertObject(mS)
        doc.InsertObject(oSp)
        doc.InsertObject(sSp)
        
    #Clone new Spline from rail
        rSp =sSp.GetClone()
        rSp.SetName("New spline from rail X")
        doc.InsertObject(rSp)
        #mS.Remove()
        c4d.EventAdd()

    if __name__=='__main__':
        main()



  • On 27/08/2015 at 02:16, xxxxxxxx wrote:

    Hello,

    the MoSpline object is a generator. This means it will create new geometry or in this case, it will change the points of the linked splines. But a generator won't do anything just by standing there. A generator is only executed when the whole scene is evaluated.

    So when you create the MoSpline in memory it won't do anything until it is part of a document and that document is evaluated.

    To evaluate the document you can call ExecutePasses(). As it turns out, one must call ExecutePasses() twice to execute the MoSpline object completely.

    Best wishes,
    Sebastian



  • On 27/08/2015 at 10:08, xxxxxxxx wrote:

    Thanks, Sebastian. It worked perfectly!


Log in to reply