Bug on GetActiveObjects() on R20.057?



  • I have this code

    objSel = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_SELECTIONORDER)
    print objSel[0]
    print objSel[1]
    

    When two objects selected, it errors that objSel[1] is out of range.
    It seems like the command only returns the first selected object, which correct me if I'm wrong, not the behavior in the previous versions (i.e. R19)

    Can you confirm this?

    Thank you



  • @bentraje said in Bug on GetActiveObjects() on R20.057?:

    objSel = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_SELECTIONORDER)
    print objSel[0]
    print objSel[1]

    Works fine by me.

    I have a cube and a plane primitive. With the two selected, I get a printout for both. No out of range.
    Running 20.057 (on Windows).

    <c4d.BaseObject object called 'Plane/Plane' with ID 5168 at 0x0000004C44847570>
    <c4d.BaseObject object called 'Cube/Cube' with ID 5159 at 0x0000004C448476D0>
    
    

    When I only select a single object then I get an out of range (obviously):

    IndexError: list index out of range
    

    EDIT:
    Hang on, when I make one the child of the other and have both selected, I do get an out of range.
    But this is obvious, since your active objects flag doesn't mention children. As such, you do only have a single parent object selected.

    To take children into account as being detected as selected, you need:

     objSel = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_SELECTIONORDER | c4d.GETACTIVEOBJECTFLAGS_CHILDREN )
    
    


  • @C4DS

    Thanks for the clarification. The c4d.GETACTIVEOBJECTFLAGS_CHILDREN did the trick is I am selecting within the hierarchy.

    I initially thought the flag was about selecting the children of the selected object. I was wrong.

    Thanks again. Have a great day ahead!



  • Hello,

    nothing more to add here except that we confirm and thanks @C4DS for his answer.

    Cheers
    Manuel


Log in to reply