Getting a list of objects at a given hierarchy



  • Hi,

    I have been using GetNext() and GetDown() to perform depth first visit of the scene. That works fine.

    I wish to now perform some operations a a given hierarchy level.

    Is there some GetNodeListsAtCurrentLevel() type of methods ?

    I am using the Python API with R21

    Cheers



  • Hi @nicholas_yue there is nothing builtin but the most optimized way I think will be

    import c4d
    
    def GetNodeListsAtCurrentLevel(bl2D):
        parent = bl2D.GetUp()
        if parent is None:
            parent = bl2D.GetListHead()
    
        return parent.GetChildren()
    
    def main():
        print GetNodeListsAtCurrentLevel(doc.GetActiveTag())
    
    # Execute main()
    if __name__=='__main__':
        main()
    

    Cheers,
    Maxime.


Log in to reply