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

    How to Update per frame

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 540 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 09/10/2011 at 17:33, xxxxxxxx wrote:

      hey everyone. i was wondering how one would go about updating a python plugin by checking for a frame change? any help is greatly appreciated. im running into trouble because when i have the object cache optimization turned on, i cant seem to update or check for anything once the cache has been built. how to i get it to update the cache on a frame by frame basis?

      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 10/10/2011 at 04:43, xxxxxxxx wrote:

        Hi avd007, in your case turn of the "Optimize Cache" attribute of your Python Generator so
        it will be triggered on all events. To avoid a massive slowdown of your generator for complexe
        geometry add the two lines #1, #2 to your generator which do the same as "Optimize Cache".
        But now you can add custom conditions when you return the cache of your object.

        import c4d
        #Welcome to the world of Python
          
        def main() :
            dirty = op.CheckCache(hh) or op.IsDirty(c4d.DIRTY_DATA) #1
            if dirty is False and not framechanged and ... : return op.GetCache(hh) #2
            
            return c4d.BaseObject(c4d.Ocube)
        
        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 10/10/2011 at 06:00, xxxxxxxx wrote:

          You could also check if the frame did really change.

          prev        = type("", (), {})()     # create a new empty type and instantiate it  
          prev.frame  = 0  
          prev.cache  = None  
            
          def **main** () :  
            frame   = doc.GetTime().GetFrame(doc.GetFps())  
            if frame != prev.frame:  
                prev.frame  = frame  
                # continue ..  
                  prev.cache  = objectToReturn  
                return objectToReturn  
            else:  
                return prev.cache
          
          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 10/10/2011 at 16:16, xxxxxxxx wrote:

            word! thanks for the quick response guys! they both work great!

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