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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    The cloner is calculated before the Python tag

    Cinema 4D SDK
    2023 python
    2
    2
    347
    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.
    • L
      ll2pakll
      last edited by

      Good afternoon, friends. I have a spline formula in my scene, which is used as an object with clones on its vertices. This spline is modified by a formula which is regulated by an expression in a python tag.

      from typing import Optional
      import c4d
      import math
      def main() -> None:
          doc: c4d.documents.BaseDocument = op.GetDocument()
          wave_obj = doc.SearchObject('Wave 1')
      
          wave_obj[c4d.PRIM_FORMULA_TMAX] = 33
          velocity_factor = doc.GetTime().Get() * 100
          wave_obj[c4d.PRIM_FORMULA_Y] = f"{str(20)}*Sin((t-{str(math.radians(velocity_factor))})*{str(0.8)})"
          # Update the scene
          c4d.EventAdd()
      

      The problem is that the cloner executes before the expression, and for this reason, the clones are placed not on the current vertices of the spline, but on the positions of vertices from the previous frame. If you stop the animation, then at the next update of the scene clones become on the right places, but during the animation they still lag a frame. I've tried changing this by decreasing or increasing the tag priority, but it has no effect. How can I solve this problem?

      i_mazlovI 1 Reply Last reply Reply Quote 0
      • i_mazlovI
        i_mazlov @ll2pakll
        last edited by

        Hi @ll2pakll ,

        Please excuse the delay, your topic somehow slipped from my list.

        I can only speculate here, as you haven't attached a sample scene that highlights your issue.

        The way you describe the problem it looks like a priority issue of the python tag. Please have a look at how the priority works in our documentation: https://help.maxon.net/c4d/2023/en-us/Default.htm#html/TPYTHON-OBASELIST.html#EXPRESSION_PRIORITY

        Also note that it's forbidden to call c4d.EventAdd() (or in reality is just skipped) from the python tag due to multithreading restrictions (c4d.EventAdd() is executed on main thread whilst python tag is executed in a parallel thread):
        9ddbfeab-53dd-49e1-8ded-0a6c3dddba94-image.png

        Cheers,
        Ilia

        MAXON SDK Specialist
        developers.maxon.net

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