Updade script only after frame change?



  • On 20/05/2016 at 06:28, xxxxxxxx wrote:

    Hello community,

    I'm very green to python but working on it :)
    So I haven't found something useful in the web or here with the search... so I hope someone can help me.
    I've a script that needs to be updated only if the actual frame is changed! Is this possible?

    My version is the R17 Student on win 10.

    Best regards
    liquidlights



  • On 20/05/2016 at 13:46, xxxxxxxx wrote:

    Hi
    Can you use a Python Tag on a null object? That will run on every frame.

    -b



  • On 23/05/2016 at 07:22, xxxxxxxx wrote:

    Hi liquidlights,

    welcome to the Plugin Café forums 🙂

    As you say, that you have a script that needs to be updated per frame, are you talking about a script in the sense of a script in C4D's Script Manager. Then the answer is: No, it's not possible. Such a script runs only, when it is executed by the user.

    Bonsak's suggestion would be one way to achieve something being "constantly" evaluated. But you have to be aware that the script of a Python tag is run within the scene evaluation pipeline.

    This has several implications:
    The code is not only run, when the current frame is changed, but on several other occasions as well. So for your purpose you will have to store the document time (GetTime()) and compare if it changed.
    More important, your code is executed in a threaded context and you are not allowed to do any changes to the scene (apart from your tag and its parent object).

    I hope this helped.


Log in to reply