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

    What's wrong with GetSelection()?

    Cinema 4D SDK
    r21 python
    3
    7
    812
    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.
    • CairynC
      Cairyn
      last edited by Cairyn

      Hello;

      I never used BaseDocument.GetSelection() before (normally the object-specific functions do fine) but I just did, and... it doesn't return the active/selected material(s). It just doesn't (the documentation says it does). It works fine with tags and objects, but the materials are ignored.

      Also, BaseDocument.SetSelection() behaves weird. If I pass a BaseMaterial, it ignores the flag SELECTION_NEW, and just selects the material in addition to those already selected. Again, it works fine for objects and tags.

      Is that a bug, or is there something wrong with my installation...?

      1 Reply Last reply Reply Quote 0
      • CairynC
        Cairyn
        last edited by

        Oh, and while I'm at it: Is BaseDocument.SetActiveObject() intentionally asymmetrical? When I use that function with c4d.SELECTION_NEW, the tag selection is cleared too, regardless of what objects the tags belong to. That does not happen vice versa with SetActiveTag(), much less with SetActiveMaterial() which is in a different manager anyway so no surprise there. I sort of assumed that the reason for that must be somewhere in the Vertical Tag mode, but after trying, I still don't see much sense in that.

        Also, I am using SetActiveObject(None, c4d.SELECTION_NEW) to clear the selection - the documentation does not indicate that None is allowed in this context (on the contrary, it demands the passed object be in the object tree already). As there is no ClearSelection() anywhere, I assume this must be the recommended method.

        1 Reply Last reply Reply Quote 0
        • ferdinandF
          ferdinand
          last edited by ferdinand

          Hi,

          there is indeed some wonky behavior going on in SetSelection(), there was a similar thread just recently. I assume you are aware of this, but note, that the selection related methods in BaseDocument are just convenience methods for the BaseList2D bit c4d.BIT_ACTIVE. So it is relatively simple to write your own functions to do what you want.

          Cheers
          zipit

          MAXON SDK Specialist
          developers.maxon.net

          CairynC 1 Reply Last reply Reply Quote 0
          • CairynC
            Cairyn @ferdinand
            last edited by

            @zipit Thanks for the confirmation (I seem to have used the wrong search criteria, but the only recent thread containing GetSelection() didn't have the desired info). Yes, I can go directly to the bit level if needed, I'm just checking out the "less used" API methods and their quirks.

            1 Reply Last reply Reply Quote 0
            • ferdinandF
              ferdinand
              last edited by

              I was referring to this [1] thread here. It does neither explicitly name SetSelection as the culprit, nor provide any solutions however.

              Cheers,
              zipit

              [1] https://developers.maxon.net/forum/topic/11953/attribute-manager-not-updating-with-tag-selection

              MAXON SDK Specialist
              developers.maxon.net

              CairynC 1 Reply Last reply Reply Quote 1
              • CairynC
                Cairyn @ferdinand
                last edited by

                @zipit Ah, of course. Didn't match my search because it's not containing GetSelection() anywhere, but I actually read that. (Useful on the topic of refreshing the Attribute Manager.)

                1 Reply Last reply Reply Quote 0
                • M
                  m_adam
                  last edited by m_adam

                  Hi @Cairyn thanks for spotting it out, it's an issue in the python documentation, if you take a look at the C++ documentation it's said that it supports only Objects and Tags (see BaseDocument Selections Manual). (I will fix the Python doc)

                  On other hand, I confirm to deselect all objects/tags the best way is to call SetSelection with None/nullptr.

                  And finally, as zipit said, in the end, it's only a wrapper around BIT_ACTIVE with the benefic of GetSelection, that the selection is cached so you avoid the iteration on the whole scene.

                  Cheers,
                  Maxime.

                  MAXON SDK Specialist

                  Development Blog, MAXON Registered Developer

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