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
    • Recent
    • Tags
    • Users
    • Login

    PythonGenerater and Object not alive

    Scheduled Pinned Locked Moved PYTHON Development
    2 Posts 0 Posters 241 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

      On 24/10/2015 at 16:19, xxxxxxxx wrote:

      Hello everybody,

      the code below is just a light version for showing the problem.
      Instead of

      obj.SetPoint(0, obj.GetPoint(0)+c4d.Vector(100,100,100)) 
      

      there is alot of calculating. That´s why I want the reference object to be checked if it is dirty. The easiest way i found is the GetAndCheckHierarchyClone()-method, because it returns True or False for nested objects like SplineMask as well. Howevery...

      With the following code everything works fine as long as the reference object ist dirty. Otherwise the console tells me 'ReferenceError: the object 'c4d.SplineObject' is not alive'. But

      print op.GetCache()
      

      prints '<c4d.SplineObject object called 'Spline Mask/Spline' with ID 5101 at 0x00000000113B27F0>'.

      What is wrong?

      import c4d  
      #Welcome to the world of Python  
        
        
      def main() :  
        first = op.GetDown()  
        dic = op.GetAndCheckHierarchyClone(hh, first, c4d.HIERARCHYCLONEFLAGS_0, False)  
          
        if dic["dirty"] or op.IsDirty(c4d.DIRTY_DATA) or not op.GetCache() :  
            obj = c4d.utils.SendModelingCommand(c4d.MCOMMAND_CURRENTSTATETOOBJECT,[first],c4d.MODELINGCOMMANDMODE_ALL,c4d.BaseContainer(),doc)[0]  
              
            if not obj.CheckType(c4d.Ospline) : return None  
            else: obj.SetPoint(0, obj.GetPoint(0)+c4d.Vector(100,100,100))  
              
        else:  
            print op.GetCache()  
            obj = op.GetCache()  
              
        first.Touch()  
        return obj
      

      OptimizeCache and ResetOnFrame0 are unchecked.

      Greetings
      rownn

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

        On 25/10/2015 at 05:37, xxxxxxxx wrote:

        Ok, thing I got it.

        Instead

        obj = op.GetCache()
        

        I use

        obj = op.GetCache().GetClone()
        

        now and it seems to work.

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