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

    what are dead objects ?

    PYTHON Development
    0
    13
    1.1k
    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
      Helper
      last edited by

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

      On 28/11/2012 at 04:53, xxxxxxxx wrote:

      hi,

      i am looping through some InExcludeData data and smashing everything with SMC CSTO. 
      everything works as expected, but i am doing this the first time for a mograph cloner object and
      this gives me some weird console output :

      <c4d.SplineObject object called 'parametric/Spline' with ID 5101 at 0x000000001BB5A730>
      <c4d.SplineObject object called 'basic/Spline' with ID 5101 at 0x000000001BB28CF0>
      ----> cloner
      <dead c4d.SplineObject object at 0x000000001BB28EF0>
      <dead c4d.SplineObject object at 0x000000001BB28F30>
      <dead c4d.SplineObject object at 0x000000001BB28DB0>
      <dead c4d.SplineObject object at 0x000000001BB28D70>
      <dead c4d.SplineObject object at 0x000000001BB28CB0>
      <dead c4d.SplineObject object at 0x000000001BB289F0>
      

      what are dead splines ? i cannot insert them into the document for observation, as c4d says

      ReferenceError: the object 'c4d.SplineObject' is not alive
      

      the cloner contains only one parametric(circle) spline object, cloning it six times. CSTOing this cloner manually results in a null with six SplineObjects in it.

      some code:

      def getSplines(InExclude) :
          result = []
          for i in range (InExclude.GetObjectCount()) :
              obj = InExclude.ObjectFromIndex(doc, i)
              if (obj.CheckType(c4d.Ospline)) :
                  result.append(obj)
                  children = obj.GetChildren()
                  if(children != None) :
                      result += iterateObjectTree(children)
              else :
                  smc = u.SendModelingCommand(command = c4d.MCOMMAND_CURRENTSTATETOOBJECT,
                                              list = [obj],
                                              doc = doc)[0]
                                      
                  if (smc.CheckType(c4d.Ospline)) :
                      result.append(smc)
                  children = smc.GetChildren()
                  if(children != None) :
                      result += iterateObjectTree(children)
          return result
          
      def iterateObjectTree(objectList) :
          result = []
          for obj in objectList:
              if (obj.CheckType(c4d.Ospline)) :
                      result.append(obj)
              children = obj.GetChildren()
              if(children != None) :
                  result += iterateObjectTree(children)
          return result
      

      what are dead objects ? is this caused by wrong smc settings ? i have tried different smc modes, but the results were the same.

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

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

        On 28/11/2012 at 07:06, xxxxxxxx wrote:

        the cloner has nothing to do with it. the objects *die* as soon as you try to csto a hierarchy which has a null object at top level.

        this will return 6 dead SplineObjects ( "Null" is passed to SMC) :

        while this will return 6 perfectly healthy SplineObjects ("Flower" is passed to SMC) :

        but the funny thing is, even if i convert the parametric spline inside the cloner into SplineObject,
        SMC still returns "dead" objects.

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

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

          On 28/11/2012 at 09:17, xxxxxxxx wrote:

          In your inexclude list try pick objects with doc as None
          Sebastian once showed that (but can get "funny" in expressions)

          obj = InExclude.ObjectFromIndex(None, i)
          

          And as for "obj is not alive"
          you may need to work on a clone instead in your CSTO.

          Cheers
          Lennart

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

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

            On 28/11/2012 at 11:42, xxxxxxxx wrote:

            hey,

            thanks for your reply. when i change

            obj = InExclude.ObjectFromIndex(doc, i)
            

            to

            obj = InExclude.ObjectFromIndex(None, i).GetClone(c4d.COPYFLAGS_NO_MATERIALPREVIEW)
            

            it doesn't change much. the smc returns one dead spline instead of the amount set in the cloner. is 
            cloning meant in a different way ? i have to admit i always kind of ignored that topic "clone xyz, or it 
            will blow up into your face", as it didn't really caused me any trouble in the past, even if the sdk said 
            so 🙂

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

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

              On 28/11/2012 at 14:12, xxxxxxxx wrote:

              Are you doing this in an expression rather than a command,
              as you are using a InEx List?

              Cheers
              Lennart

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

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

                On 28/11/2012 at 14:16, xxxxxxxx wrote:

                i am doing this from a python xpresso node.

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

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

                  On 28/11/2012 at 14:35, xxxxxxxx wrote:

                  Then don't 🙂
                  It's living on the edge modifying the document at runtime.
                  Generally do this in a command (that you call from your xpresso node (havent tried))
                  or in a message body of an expression (so you can control the document while executing)

                  Cheers
                  Lennart

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

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

                    On 28/11/2012 at 15:15, xxxxxxxx wrote:

                    hey,

                    thanks for your help. with "do this in a command" you suggest using a CommandData plugin ?

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

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

                      On 28/11/2012 at 16:00, xxxxxxxx wrote:

                      A regular Command script could do, unless you want to call it from
                      something else. Then a registered Command Plugin would be better
                      as you can call it by it's Plugin ID. (Command scripts tend to change their
                      ID over time, strangely enough)

                      Cheers
                      Lennart

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

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

                        On 29/11/2012 at 01:44, xxxxxxxx wrote:

                        hm,

                        doesn't change anything.

                        - script version
                        - more explicit usage of SMC CSTO
                        - did the clone object/document thing the sdk suggests for CSTO

                        something doesn't feel right, i am either making a fundamental mistake, or smc is bugged (again)
                        at that point. never had to do all this cloning stuff in the past. there is also the fact, that when you 
                        start cloning things before smc (the object, the document or both) the smc just returns one object.
                        or in other words - is just ignoring the cloner (although I explicitly set NOGENERATE to False in its
                        settings).

                        i am also pretty unsure about this documents.IsolateObjects() method thing. do i have to search 
                        my objects in the document by myself or is the passed object list now automatically referencing 
                        objects in the new document ?

                        import c4d
                        from c4d import utils as u
                        from c4d import documents
                          
                        def main() :
                            userData =  doc.SearchObject("UserData")
                            objList = inExclude2List(userData[c4d.ID_USERDATA,1])
                            splines = getSplines(objList)
                            for n in splines:
                                print n
                          
                        def inExclude2List(InExclude) :
                            result = []
                            for i in range (InExclude.GetObjectCount()) :
                                result.append(InExclude.ObjectFromIndex(doc, i))#.GetClone(c4d.COPYFLAGS_CACHE_BUILD))
                            return result
                          
                        def getSplines(objects) :
                            result = []
                            cloneDoc = documents.IsolateObjects(doc, objects)
                            # doesn't change anything
                            # objects = []
                            # objects.append(cloneDoc.GetFirstObject())
                          
                            for obj in objects:
                                if (obj.CheckType(c4d.Ospline)) :
                                    result.append(obj)
                                    children = obj.GetChildren()
                                    if(children != None) :
                                        result += iterateObjectTree(children)
                                else :
                                    set = c4d.BaseContainer()
                                    set[c4d.MDATA_CURRENTSTATETOOBJECT_INHERITANCE] = True
                                    set[c4d.MDATA_CURRENTSTATETOOBJECT_KEEPANIMATION] = True
                                    set[c4d.MDATA_CURRENTSTATETOOBJECT_NOGENERATE] = False
                                    
                                    smc = u.SendModelingCommand(command = c4d.MCOMMAND_CURRENTSTATETOOBJECT,
                                                                list = [obj],
                                                                mode = c4d.MODELINGCOMMANDMODE_ALL,
                                                                bc = set,
                                                                doc = cloneDoc)[0] 
                                    print "smc", smc    
                                    if (smc.CheckType(c4d.Ospline)) :
                                        result.append(smc)
                                    children = smc.GetChildren()
                                    if(children != None) :
                                        result += iterateObjectTree(children)
                            return result
                            
                        def iterateObjectTree(objectList) :
                            result = []
                            for obj in objectList:
                                if (obj.CheckType(c4d.Ospline)) :
                                        result.append(obj)
                                children = obj.GetChildren()
                                if(children != None) :
                                    result += iterateObjectTree(children)
                            return result
                            
                          
                        if __name__=='__main__':
                            main()
                        

                        edit: just for the record - console output for this is :

                        smc <c4d.BaseObject object called 'Cloner/Null' with ID 5140 at 0x0000000006E180D0>
                        <dead c4d.SplineObject object at 0x000000000FD185F0>
                        

                        edit no. 543957 :

                        also the whole - cloner objects aren't the cause for dead objects, but null objects thing applies also to this script version.

                        imghttp://oi47.tinypic.com/1zoetll.jpg

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

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

                          On 29/11/2012 at 05:28, xxxxxxxx wrote:

                          This is a variable scope problem. If you print the splines at the end of getSplines(), before returning them, they're valid.
                          But once the list is returned to main(), splines are no more valid because they were stored in a local list and they don't belong to any document.

                          To resolve this, you should create a new document in your main() and then pass it to getSplines() in order to insert the resulting object for SMC CSTO.

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

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

                            On 29/11/2012 at 07:38, xxxxxxxx wrote:

                            I'm not sure what you are getting at in the end
                            but the following works fine.

                            Cheers
                            Lennart

                              
                            import c4d   
                            from c4d import gui, utils as u   
                              
                            #CSTO   
                            def csto(obj) :   
                                csto_bc     = c4d.BaseContainer()   
                                csto_objs   = u.SendModelingCommand(   
                                    command = c4d.MCOMMAND_CURRENTSTATETOOBJECT,   
                                    list    = [obj],       
                                    mode    = c4d.MODELINGCOMMANDMODE_ALL,   
                                    bc      = csto_bc,   
                                    doc     = obj.GetDocument())   
                                return csto_objs[0]   
                              
                            def main() :   
                                act_obj = doc.GetActiveObjects(False)[0] # First Active Object with an Userdata InEx List   
                                if not act_obj: return True # Nothing Selected   
                                try: inexlist = act_obj[c4d.ID_USERDATA,1]   
                                except: return True # Emty or no list   
                              
                                doc.StartUndo()   
                              
                                for i in xrange(inexlist.GetObjectCount()) :   
                                    o = inexlist.ObjectFromIndex(None,i)   
                                    cobj = csto(o)   
                                    doc.AddUndo(c4d.UNDOTYPE_NEW,cobj)   
                                    doc.InsertObject(cobj,None,None)   
                                   
                                c4d.EventAdd()   
                                doc.EndUndo()   
                              
                            if __name__=='__main__':   
                                main()   
                            
                            1 Reply Last reply Reply Quote 0
                            • H
                              Helper
                              last edited by

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

                              On 29/11/2012 at 10:52, xxxxxxxx wrote:

                              Originally posted by xxxxxxxx

                              This is a variable scope problem. If you print the splines at the end of getSplines(), before returning them, they're valid.
                              But once the list is returned to main(), splines are no more valid because they were stored in a local list and they don't belong to any document.

                              To resolve this, you should create a new document in your main() and then pass it to getSplines() in order to insert the resulting object for SMC CSTO.

                              this solved my problem, thanks 🙂

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