The cloner is calculated before the Python tag
-
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?
-
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):
Cheers,
Ilia