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

    Selecting all children in a Root Null-Object

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 345 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 26/11/2012 at 01:34, xxxxxxxx wrote:

      Selecting all children in a Root Null-Object.

      I was trying to make it happen but I guess this is a logic problem I need your help.

      at the moment i use the callcomand but i guess this is not the fasted solution to select all children in a Null-Object.

      op.SetBit(c4d.BIT_ACTIVE)   
      c4d.CallCommand(100004768) # Unterobjekte selektieren - select children                 
      c4d.CallCommand(16768) # Objekte verbinden + Löschen Connect and delete
      

      kind regards
      mogh

      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 26/11/2012 at 10:50, xxxxxxxx wrote:

        If you need to select all children you need to
        use a recursive function such as below.
        To keep the selection to the hierarchy of the
        selected object, you add a obj.GetNext() so it
        knows where to stop (or it would select everything
        from selected object to the end of the OM.

        Cheers
        Lennart

          
        import c4d   
        from c4d import gui   
          
        def selchildren(obj,next) : # Scan obj hierarchy and select children   
            while obj and obj != next:   
                doc.AddUndo(c4d.UNDOTYPE_CHANGE_SMALL,obj)   
                obj.SetBit(c4d.BIT_ACTIVE)   
                selchildren(obj.GetDown(),next)   
                obj = obj.GetNext()   
            c4d.EventAdd()   
            return True   
          
        def main() :   
            try: obj = doc.GetActiveObjects(False)[0]   
            except: return True # Nothing Selected   
          
            doc.StartUndo()   
            if selchildren(obj,obj.GetNext()) :   
                c4d.CallCommand(16768) #Connect And Delete   
          
            doc.EndUndo()   
          
        if __name__=='__main__':   
            main()
        
        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 26/11/2012 at 23:53, xxxxxxxx wrote:

          Thanks tcastudios, this is about 60% faster then the callcomand exactly what i needed.

          works perfect.

          just to understand your code: you are calling the function from itself? with different parameters? thats crazy stuff 😉

          also this line buffles me : try: obj = doc.GetActiveObjects(False)[0]
          does this read like "Try to set OBJ, and if 0 set to False"

          much more to learn young jedi
          kind regards mogh

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