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

    Set Tracers "trace link" (inExclude) field from python tag

    Cinema 4D SDK
    r20 python
    2
    3
    710
    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
      bonsak
      last edited by bonsak

      Hi
      Im trying to set the Tracer objects "Trace link" inExclude list from a python tag.
      I dont get any errors and the GetObjectCount method returns the correct number of objects, but none are visible in the list itself. Any help appreciated. See attached file for example.

      import c4d
      
      def main():
          # Get userdata from parent
          root = op.GetObject().GetUp()[c4d.ID_USERDATA,1]
      
          # Get first joint
          hipJoint = root.GetDown()
          # Get second joint
          kneeJoint = hipJoint.GetDown()
        
          # Get the tracers inExclude field
          tracerList = op.GetObject()[c4d.MGTRACEROBJECT_OBJECTLIST]
      
          # Insert hip
          tracerList.InsertObject(hipJoint, 1)
          # Insert knee
          tracerList.InsertObject(kneeJoint, 1)
          
          # Returns 2 but none are visible in the tracers inExclude field
          print tracerList.GetObjectCount()
      

      Regards
      Bonsak

      0_1542205877232_inexclude-python-update.c4d

      1 Reply Last reply Reply Quote 0
      • S
        s_bach
        last edited by

        Hello,

        when you "get" the InExclude list in Python, you get a copy of the value, not a reference.

        After editing the copy you have to store the new value again in the original object:

        # get data
        tracerList = op.GetObject()[c4d.MGTRACEROBJECT_OBJECTLIST]
        
        # modify data
        
        #store data
        op.GetObject()[c4d.MGTRACEROBJECT_OBJECTLIST] = tracerList
        

        But remember: a tag is executed every time the scene is evaluated. So the objects are added to the list again and again. You could maybe check if the list is empty and return if that is not the case:

        if tracerList.GetObjectCount() > 0:
            return
        

        Please also use the Q&A system to mark your threads as questions.

        Best wishes,
        Sebastian

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 2
        • B
          bonsak
          last edited by

          Awesome! Thanks.

          Regards
          Bonsak

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