Solved Attribute Manager not updating with Tag Selection

I am selecting tags on an object with python and once the selection is set the attribute manager doesn't update with the tag's attributes. It will if you only have any tag selected before the selection but if an object is selected or nothing is selected the attribute manager won't display anything when the tag is selected:/

Any idea how to get the tag's properties to show up without manually selecting it?

Here is simplified code to illustrate the issue. If you just make a cube primitive and select it this code will select the phong tag. But again the properties of the phong tag dont show up.

import c4d
from c4d import gui

def main():
    obj = doc.GetActiveObject()
    tags = obj.GetTags()
    doc.SetSelection(tags[0])
    c4d.EventAdd()
    
# Execute main()
if __name__=='__main__':
    main()

Hi,

you can do this:

import c4d

def main():
    # op is perdefined as the currently selected node
    if not isinstance(op, c4d.BaseObject):
        return
    # get the tags of op
    tags = op.GetTags()
    if not tags:
        return

    # start a new selection with the first tag
    doc.SetActiveTag(tags[0], c4d.SELECTION_NEW)
    # add the other tags to the selection
    for tag in tags[1:]:
        doc.SetActiveTag(tag, c4d.SELECTION_ADD)
    # Update Cinema
    c4d.EventAdd()

# Execute main()
if __name__=='__main__':
    main()

Cheers
zipit

MAXON SDK Specialist
developers.maxon.net

Hi,

you can do this:

import c4d

def main():
    # op is perdefined as the currently selected node
    if not isinstance(op, c4d.BaseObject):
        return
    # get the tags of op
    tags = op.GetTags()
    if not tags:
        return

    # start a new selection with the first tag
    doc.SetActiveTag(tags[0], c4d.SELECTION_NEW)
    # add the other tags to the selection
    for tag in tags[1:]:
        doc.SetActiveTag(tag, c4d.SELECTION_ADD)
    # Update Cinema
    c4d.EventAdd()

# Execute main()
if __name__=='__main__':
    main()

Cheers
zipit

MAXON SDK Specialist
developers.maxon.net

Thank you!
doc.SetActiveTag() was the key.
doc.SetSelection() was not switching it over to tag mode.

you can also make use of

c4d.gui.ActiveObjectManager_SetObject

to let the Attribute Manager (= ActiveObjectManager) show to content of the 'object'. Where 'object' can be anything from mesh object to tag, material, shader, ...

@C4DS Thank your reply! I had to come back to this because I had problems with switching back to object context and this solved that!