execute python tag code only on event



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/05/2012 at 09:16, xxxxxxxx wrote:

    Hi everyone,

    I've a loop inside of a python tag that I would like to execute just once, each time the interface refreshes. Is that possible ?

    To be more specific, inside the tag I have code that iterates through userdata to check theyre state, and hides/shows other UD according to that. Basically if a checkbox is ON, a specific field will be hidden and viceversa.
    This is actually working, I got at this point thanks to ScottA, nux95 and many other posters here and on CGTalk.. but the problem is that the code is looping continuosly (and I have maaaany userdata) hence eating up some processing power.
    I was wondering if that loop can be triggered for example only when the checkbox is pressed, or on some other interface update. Or maybe if there is a more efficient way to do the same thing..

    I made a simplified version of the file, you can download it from here: http://www.visualtricks.it/screenshots/hide_userdata.c4d.zip

    thanks
    Massimiliano



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/05/2012 at 12:10, xxxxxxxx wrote:

    Hello visualtricks!

    You can check for changed parameters on an object:

    import c4d   
    prev_state = -1   
      
    def main() :   
        global prev_state   
        state = op.GetDirty(c4d.DIRTY_DATA)   
        if state != prev_state:   
            # parameters have changed!   
        prev_state = state
    

    Best,
    -N



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 25/05/2012 at 01:19, xxxxxxxx wrote:

    Hi NiklasR, thanks for your reply !
    Is that code working for any change (like an userdata checkbox pressed) or just for "phisical" changes in a object (like scale or position changes) ? 
    I'll give it a try anyway :)

    cheers
    Massimiliano



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 25/05/2012 at 03:52, xxxxxxxx wrote:

    Hi Massimilano,

    GetDirty() with the DIRTY_DATA flag returns number of changes made to the object's parameters. If that number differs from the number you got from the last time you called it, the parameters have changed.
    Not quite sure if the dirty-count is also affected when setting value programatically, can't test it, but it should.

    Cheers,



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 28/05/2012 at 03:59, xxxxxxxx wrote:

    Just want to say thanks again, that little bit of code saved my life :)

    Cheers
    Massimiliano


Log in to reply