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

    World Dynamics Cache Buttons

    Scheduled Pinned Locked Moved PYTHON Development
    6 Posts 0 Posters 471 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 03/05/2012 at 10:11, xxxxxxxx wrote:

      I see that FindSceneHook() has been added to R13 so we can set the project settings now.
      I'm converting my C++ project settings code to python. But the only ones I can't figure out how to write are the two Dynamics cache buttons.

      Example:

      import c4d  
      def main() :  
        
        sh = doc.FindSceneHook(180000100)  
        c4d.CallButton(doc,c4d.WORLD_CACHE_BAKE)  #Does not work  
        c4d.CallButton(doc,c4d.WORLD_CACHE_CLEAR) #Does Not work  
          
        c4d.EventAdd()  
        
      if __name__=='__main__':  
        main()
      

      Are these buttons supported?
      If so...How do we execute them?

      -ScottA

      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 03/05/2012 at 16:54, xxxxxxxx wrote:

        Never Mind. I managed to figure it out.

        import c4d  
        def main() :  
            
          sh = doc.FindSceneHook(180000100)   
          c4d.plugins.FindPlugin(c4d.PLUGINTYPE_SCENEHOOK)  
          c4d.CallButton(sh, c4d.WORLD_CACHE_BAKE)   #Executes the Bake button  
          c4d.CallButton(sh, c4d.WORLD_CACHE_CLEAR)  #Executes the Clear button  
          c4d.EventAdd()      
            
        if __name__=='__main__':  
          main()
        

        -ScottA

        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 04/05/2012 at 05:13, xxxxxxxx wrote:

          eh, sould have looked here first, i have answered the cgtalk post already, but IMHO your first
          example is already almost correct, but you have to pass sh instead of doc. the script won't throw
          an error, as doc a BaseDocument is also a BeseList2D, but CallButton expects the object which
          contains the id passed as the second parameter, so you have to pass sh. it makes no sense to 
          define sh and then not not to use it.

          the same goes for c4d.plugins.FindPlugin(c4d.PLUGINTYPE_SCENEHOOK) (plus this line doesn't 
          really make any sense to me, does this actually return a BaseList2D ?). also EventAdd() isn't 
          necessary in that case.

          shortest form would be :

          c4d.CallButton(doc.FindSceneHook(180000100), c4d.WORLD_CACHE_BAKE)
          
          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 04/05/2012 at 08:41, xxxxxxxx wrote:

            Now I can't figure out how to change any of the Key Interpolation settings.

                sh = doc.FindSceneHook(180000100)  
              sh[c4d.TLWORLD_OVERDUB]=True  #Does Nothing!  
              c4d.EventAdd()
            

            -ScottA

            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 04/05/2012 at 10:08, xxxxxxxx wrote:

              180000100 is only the id to the MographDynamics hook if i am not mistaken, you have to get the id 
              of the Key Interpolation Tab from the ressource folder i think.

              edit :

              the  c4d console says  for KeyInterpolation :

              [OK] KeyInterpolation
              <c4d.BaseList2D object called 'Key Interpolation/Key Interpolation' with ID 465001535 at 0x10B54050>
              

              i haven't tested / i am not quite sure if this is the correct id to get the hook.

              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 04/05/2012 at 11:02, xxxxxxxx wrote:

                Thanks. That is the correct ID#.

                Here's a list of how to change all of the Project Settings:

                ##### Scene Scale & Units options  
                  
                import c4d  
                  
                def main() :      
                  
                  pScale = doc[c4d.DOCUMENT_DOCUNIT]    #Get the ProjectScale value  
                  value = c4d.UnitScaleData             #Create a UnitScaleData type variable      
                  pScale.SetUnitScale(1.0, c4d.DOCUMENT_UNIT_CM) #Change the Scene's scale and measure type settings  
                  doc[c4d.DOCUMENT_DOCUNIT]=pScale      #Make the changes happen from memory  
                  doc.Message(c4d.MSG_UPDATE)           #Update C4D about the changes  
                  c4d.EventAdd()  
                  
                if __name__=='__main__':  
                  main()  
                  
                  
                  
                  
                ##### Project Settings  
                  
                #Set up BaseTime so we can use it later on in the attributes  
                fps = doc.GetFps()    
                frame = doc.GetTime().GetFrame(doc.GetFps())  
                  
                  
                # doc[c4d.DOCUMENT_DOCUNIT]= See above  
                doc[c4d.DOCUMENT_FPS] = 30                           # Sets the FPS attribute  
                doc[c4d.DOCUMENT_TIME]= c4d.BaseTime(0, fps)         # The frame where the scrubber starts   
                doc[c4d.DOCUMENT_MINTIME]= c4d.BaseTime(0, fps)      # The start frame value   
                doc[c4d.DOCUMENT_MAXTIME]= c4d.BaseTime(90, fps)     # The end Frame value   
                doc[c4d.DOCUMENT_LOOPMINTIME]=c4d.BaseTime(0, fps)   # The Preview option Start time  
                doc[c4d.DOCUMENT_LOOPMAXTIME]=c4d.BaseTime(90, fps)  # The Preview option End time  
                  
                  
                doc[c4d.DOCUMENT_LOD]=1.0                      # Level of Detail          
                doc[c4d.DOCUMENT_RENDERLOD]=False              # Render LOD in Editor  
                doc[c4d.DOCUMENT_USEANIMATION]=True            # Use Animation  
                doc[c4d.DOCUMENT_USEEXPRESSIONS]=True          # Use Expressions  
                doc[c4d.DOCUMENT_USEGENERATORS]=True           # Use Generators  
                doc[c4d.DOCUMENT_USEDEFORMERS]=True            # Use Deformers  
                doc[c4d.DOCUMENT_USEMOTIONSYSTEM]=True         # Use Motion System  
                doc[c4d.DOCUMENT_DEFAULTMATERIAL_TYPE]= 1      # 0=WHITE, 1=GREY-BLUE, 2=USER  
                doc[c4d.DOCUMENT_CLIPPING_PRESET]=1            # 3=TINY, 0=SMALL, 1=MEDIUM, 2=LARGE, 4=HUGE, 5=CUSTOM  
                doc[c4d.DOCUMENT_CLIPPING_PRESET_NEAR]=1.0     # Sets the Near clipping value  
                doc[c4d.DOCUMENT_CLIPPING_PRESET_FAR]=100000.0 # Sets the Far clipping value  
                doc[c4d.DOCUMENT_LINEARWORKFLOW]=True          # Use Linear Workflow  
                doc[c4d.DOCUMENT_COLORPROFILE]=1               # 0=SRGB, 1=LINEAR, 2=DISABLED;  
                  
                  
                  
                  
                ///// Info Settings  
                  
                doc[c4d.DOCUMENT_INFO_AUTHOR]= ""     //Type your name in here  
                doc[c4d.DOCUMENT_INFO_COPYRIGHT]= ""  //Type your copyright info here  
                doc[c4d.DOCUMENT_INFO_README]= ""    // Type your notes here  
                  
                  
                ///// Dynamics Settings  
                  
                sh = doc.FindSceneHook(180000100)  
                sh[c4d.WORLD_ENABLED]=True  
                sh[c4d.WORLD_DISABLE_DURING_LEAP]=True  
                sh[c4d.WORLD_TIMESCALE]=1.0  
                sh[c4d.WORLD_GRAVITY]=1000.0  
                sh[c4d.WORLD_DENSITY]=1.0  
                c4d.EventAdd()    
                  
                  
                 //CACHE  
                  
                fps = doc.GetFps()    
                frame = doc.GetTime().GetFrame(doc.GetFps())  
                sh = doc.FindSceneHook(180000100)  
                  
                c4d.CallButton(doc.FindSceneHook(180000100), c4d.WORLD_CACHE_BAKE)   //Executing the Bake dynamics cache buttons  
                c4d.CallButton(doc.FindSceneHook(180000100), c4d.WORLD_CACHE_CLEAR)  //Execute the Clear dynaimcs cache button   
                              
                sh[c4d.WORLD_CACHE_USE]=False  
                sh[c4d.WORLD_CACHE_DISABLE_BAKED_OBJECTS]=False  
                sh[c4d.WORLD_CACHE_USE_TIME]=False  
                sh[c4d.WORLD_CACHE_TIME]=c4d.BaseTime(0, fps)  
                c4d.EventAdd()  
                  
                  
                 //EXPERT  
                sh = doc.FindSceneHook(180000100)  
                sh[c4d.WORLD_MARGIN]=1  
                sh[c4d.WORLD_SCALE]=100  
                sh[c4d.WORLD_CONTACT_RESTITUTION_LIFETIME]=5  
                sh[c4d.WORLD_SEED]=0  
                sh[c4d.WORLD_SUBSTEPS]=5  
                sh[c4d.WORLD_ITERATIONS]=10  
                sh[c4d.WORLD_ERROR_THRESHOLD]=10      
                c4d.EventAdd()  
                  
                  
                  
                 //VISUALIZATION  
                sh = doc.FindSceneHook(180000100)  
                sh[c4d.WORLD_VISUALIZE]=False  
                sh[c4d.WORLD_VISUALIZE_SHAPES]=True  
                sh[c4d.WORLD_VISUALIZE_AABBS]=True  
                sh[c4d.WORLD_VISUALIZE_CONTACT_POINTS]=True  
                sh[c4d.WORLD_VISUALIZE_CONSTRAINTS]=True  
                c4d.EventAdd()  
                  
                  
                  //Key Interpolation  
                  
                sh = doc.FindSceneHook(465001535)  
                sh[c4d.TLWORLD_OVERDUB]=False  
                sh[c4d.TLWORLD_LOCKV]=False  
                sh[c4d.TLWORLD_AUTO]=True  
                sh[c4d.TLWORLD_LOCKTA]=False  
                sh[c4d.TLWORLD_BREAK]=False  
                  
                //Spline types  
                sh[c4d.TLWORLD_INTER]=c4d.TLWORLD_INTER_SP  #Spline type  
                sh[c4d.TLWORLD_INTER]=c4d.TLWORLD_INTER_LI  #linear type  
                sh[c4d.TLWORLD_INTER]=c4d.TLWORLD_INTER_ST  #Step   type  
                  
                sh[c4d.TLWORLD_LOCKT]=False  
                sh[c4d.TLWORLD_CLAMP]=True  
                sh[c4d.TLWORLD_LOCKTL]=False  
                sh[c4d.TLWORLD_KEEPVISUALANGLE]=False
                

                -ScottA

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