Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    GetMg() doesn't update on objects affected with Align to Spline Tag?

    Cinema 4D SDK
    python 2023
    2
    3
    603
    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.
    • B
      bentraje
      last edited by

      Hi,

      I have an object that is constrainted to a spline through align to spline tag.

      The problem is when I run a GetMg().off on before and after I revise the tag, I get the same result instead of having different values.

      What am I missing? 😞

      import c4d
      
      
      def main():
          doc = c4d.documents.GetActiveDocument()
      
          joint = c4d.BaseObject(1019362)
          doc.InsertObject(joint)
          spline = c4d.BaseObject(5181)
          doc.InsertObject(spline)
      
          spline_tag = c4d.BaseTag(5699)
          joint.InsertTag(spline_tag)
          spline_tag[c4d.ALIGNTOSPLINETAG_LINK] = spline
      
          spline_tag[c4d.ALIGNTOSPLINETAG_POSITION] = 0
          c4d.EventAdd()
          print (joint.GetMg().off) # Vector(0, 0, 0)
          spline_tag[c4d.ALIGNTOSPLINETAG_POSITION] = 0.2
          c4d.EventAdd()
          print (joint.GetMg().off) # still Vector(0, 0, 0)
      
          c4d.EventAdd()
      if __name__ == '__main__':
          main()
      
      1 Reply Last reply Reply Quote 0
      • i_mazlovI
        i_mazlov
        last edited by

        Hi @bentraje,

        you're doing everything right. The only step you're missing is to reevaluate the scene using ExecutePasses after changing the Align to Spline tag position. You can call it the following way:

        doc.ExecutePasses(None, True, True, True, c4d.BUILDFLAGS_NONE)
        

        Note, you should use c4d.BUILDFLAGS_0 instead, if you run c4d earlier than R20. This is how you can use it in a generic way:

        buildFlag = c4d.BUILDFLAGS_NONE if c4d.GetC4DVersion() > 20000 else c4d.BUILDFLAGS_0
        doc.ExecutePasses(None, True, True, True, buildFlag)
        

        Cheers,
        Ilia

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 1
        • B
          bentraje
          last edited by

          @i_mazlov

          Gotcha. Thanks. Works as expected.

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