Solved What's wrong with GetSelection()?

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...?

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.

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

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

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://plugincafe.maxon.net/topic/11953/attribute-manager-not-updating-with-tag-selection

MAXON SDK Specialist
developers.maxon.net

@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.)

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.