Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    Bug on GetActiveObjects() on R20.057?

    Cinema 4D SDK
    r20 python
    3
    4
    949
    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.
    • B
      bentraje
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • C4DSC
        C4DS
        last edited by C4DS

        @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 )
        
        
        1 Reply Last reply Reply Quote 3
        • B
          bentraje
          last edited by

          @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!

          1 Reply Last reply Reply Quote 0
          • ManuelM
            Manuel
            last edited by

            Hello,

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

            Cheers
            Manuel

            MAXON SDK Specialist

            MAXON Registered Developer

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