How can I control a Python Tag's execution?



  • Hello,
    I have 50 objects in my scene. Every object has user data values and python tag on it. After an object's user data is changed its python tag should run only one time.

    But scripts are running after whenever I changed something in the scene (or after clicking on Object manager panel's empty area too)
    I have to control this because script is a little bit heavy and my scene is heavy too. But every time scripts are running.

    Currently I disabled all of them. After I changed user data values of an object I execute script of that object manually. But this is a big problem actually because I use takes and user values are changed by takes. After changing active take, objects can't be refreshed via their scripts because I disabled them. So after changing active take I have to enable all python tags and disable them again. I can do this via script and a shortcut so after change active take I can re-enable tags and then disable again via that script but I wanted to ask this here.

    any idea about the situation? I hope I could explain my problem :/



  • Hi @delizade, thanks for reaching out to us.

    The PythonTag associated to an object is evaluated, by default, every time Cinema 4D evaluates the scene and this can happen even if the object has not changed at all.

    Finally, without more details on the PythonTag code, its design and the ultimate goal, I can only think about of the simple solution of caching the last userdata value in the PythonTag's container and compare, before running your tag's business logic, it against the value found in the userdata.

    Cheers, R



  • Hi @delizade, thanks for reaching out to us.

    The PythonTag associated to an object is evaluated, by default, every time Cinema 4D evaluates the scene and this can happen even if the object has not changed at all.

    Finally, without more details on the PythonTag code, its design and the ultimate goal, I can only think about of the simple solution of caching the last userdata value in the PythonTag's container and compare, before running your tag's business logic, it against the value found in the userdata.

    Cheers, R



  • thank you for that suggestion. I did not think that method frankly. I will try it.
    Currently I made all python tags as frame dependent. I wrote a script and assign it to a null object in my scene. This script checks current take and compare it previous one. If takes are different it changes current frame +1. In that way other python tags are running only one time.

    there is a issue but I could not achieve to solve it that as if some part of the script does not work properly :) anyway I guess your suggestion may help me rather than using frame dependent Python tags.

    thank you again.



  • Hi,

    without further feedback, we will consider this thread as solved by Monday and flag it accordingly.

    Cheers,
    Ferdinand


Log in to reply