Hey @lionlion44,
Well, doing what you want to do is only halfway possible. An object being soloed just means setting the flag EHIDE on all othe objects. And while there is OHIDE which can be used to hide scene elements in managers, e.g., an object in the Object Manager, it is not being used by the 'Set as Root/Path Bar'-function of the Object Manager. So, you cannot hook into that.
What you can do is just write a simple script which operates both flags for you. But to make this air-tight, you will have to implement a plugin (to avoid accidentally saving a scene with hidden elements).
Cheers,
Ferdinand
Code """Demonstrates how to set the visibility of objects in the viewport and the managers. - When CTRL is not pressed while the script is invoked, the visibility state of the selected objects is set, i.e., everything that is not selected will be hidden. - When CTRL is pressed, the visibility state of the selected objects is cleared. - When HIDE_DESCENDANTS_OF_SELECTED_OBJECTS is set to True, the descendants of selected objects will be considered selected as well. WARNING: The visibility state is written PERMANENTLY into the scene graph, i.e., when one hides objects and saves the scene, the visibility state will be saved as well. One can of course just run the script while pressing CTRL to clear the visibility state of such saved and then loaded back scene, but this could possibly brick scenes for other users. To make this air-tight, one would have to implement a plugin which handles un-hiding objects before a scene is being saved (which is not super trivial in Python atm). Use this script at your own risk. """ __author__ = "Ferdinand Hoppe" __copyright__ = "Copyright 2025, Maxon Computer GmbH" import c4d import mxutils doc: c4d.documents.BaseDocument # The currently active document. op: c4d.BaseObject | None # The primary selected object in `doc`. Can be `None`. # Wether to hide objects that are descendants of selected objects. I.e., when you have A-> B -> C, # and A is selected, B and C will be considered selected as well. HIDE_DESCENDANTS_OF_SELECTED_OBJECTS: bool = True def IsSelected(node: c4d.BaseObject) -> bool: """Returns if #node is selected or if any of its predecessors are selected (when selecting descendants implicitly is enabled). """ while node: if node.GetBit(c4d.BIT_ACTIVE): return True if not HIDE_DESCENDANTS_OF_SELECTED_OBJECTS: break node = node.GetUp() return False def SetObjectVisibility(doc: c4d.documents.BaseDocument, clearSate: bool = False) -> None: """Sets the visibility of the object in the managers and the viewport. """ for node in mxutils.IterateTree(doc.GetFirstObject(), True, True, True): isSelected: bool = clearSate or IsSelected(node) node.ChangeNBit(c4d.NBIT_OHIDE, c4d.NBITCONTROL_CLEAR if isSelected else c4d.NBITCONTROL_SET) node.ChangeNBit(c4d.NBIT_EHIDE, c4d.NBITCONTROL_CLEAR if isSelected else c4d.NBITCONTROL_SET) def main() -> None: """Called by Cinema 4D whhen the """ if not op: c4d.gui.MessageDialog("No object selected.") return state: c4d.BaseContainer = c4d.BaseContainer() if not c4d.gui.GetInputState(c4d.BFM_INPUT_MOUSE, 0, state): raise RuntimeError("Failed to get input state") ctrlIsPressed: bool = state[c4d.BFM_INPUT_QUALIFIER] & c4d.QUALIFIER_CTRL # If Ctrl is pressed, clear the visibility state, otherwise set it. SetObjectVisibility(doc, True if ctrlIsPressed else False) c4d.EventAdd() if __name__ == '__main__': main()