Selecting all children in a Root Null-Object



  • 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



  • 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()
    


  • 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


Log in to reply