What's wrong with GetSelection()?
Cairyn last edited by Cairyn
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...?
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
Noneis 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.
ferdinand last edited by ferdinand
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
BaseDocumentare just convenience methods for the
c4d.BIT_ACTIVE. So it is relatively simple to write your own functions to do what you want.
@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.
ferdinand last edited by
I was referring to this  thread here. It does neither explicitly name
SetSelectionas the culprit, nor provide any solutions however.
@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.)
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.