Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    execute python tag code only on event

    Scheduled Pinned Locked Moved PYTHON Development
    5 Posts 0 Posters 474 Views
    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.
    • H Offline
      Helper
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          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

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            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,

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              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

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