Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    Duplicate of Destination X Rail spline of a MoSpli

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 337 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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()

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

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

          Thanks, Sebastian. It worked perfectly!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post