Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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
    The forum rollback caused push notifications and recent user data to malfunction. The problem will fix itself naturally within the next days. See the topic Broken Push Notifications for a more in detail explanation. You can fix this yourself by forcibly clearing your browser cache (for most browsers: CTRL + F5).

    Automatically solo objects by using the 'path' of the object manager?

    Cinema 4D SDK
    python r25
    2
    4
    475
    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.
    • L
      lionlion44
      last edited by

      Hey there,
      I'd love to be able to automatically solo the object that are inside the current 'path' parameter in the object manager. Is this possible using python or an easier method. This way the object manager and the viewport would have continuity with each other.
      Thanks

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

        Hello @lionlion44,

        Welcome to the Maxon developers forum and its community, it is great to have you with us!

        Getting Started

        Before creating your next postings, we would recommend making yourself accustomed with our forum and support procedures. You did not do anything wrong, we point all new users to these rules.

        • Forum Overview: Provides a broad overview of the fundamental structure and rules of this forum, such as the purpose of the different sub-forums or the fact that we will ban users who engage in hate speech or harassment.
        • Support Procedures: Provides a more in detail overview of how we provide technical support for APIs here. This topic will tell you how to ask good questions and limits of our technical support.
        • Forum Features: Provides an overview of the technical features of this forum, such as Markdown markup or file uploads.

        It is strongly recommended to read the first two topics carefully, especially the section Support Procedures: How to Ask Questions.

        About your First Question

        I do not really understand your question, specifically what you mean with 'current path of the object manager' and the Object Manager and viewport having 'continuity'. An Object Manager has no 'current path' and there is also more than one Object Manager (up to four). You can already link the active object state to the solo state of the scene graph, i.e., just select objects to solo them (see below). The only way to provide more 'continuity' would be to hide objects in the Object Managers which are not soloed. That would be technically possible, but not really a good idea, as you would then have no way to deselect these soloed objects as everything else would be hidden both in the viewport and Object Managers.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • L
          lionlion44
          last edited by lionlion44

          Hey @ferdinand ,

          Thanks for the quick response. To describe my request more specifically, I was wondering if the path bar in an object manager could be used to solo objects. This way I could have multiple nulls containing different parts of the project, then by setting the root of the path bar to a null it would solo the things in that null. This would also mean I'm only seeing the soloed objects in the object manager. That's what I meant by continuity, the object manager and the viewport would have the same content.

          image.png
          image.png

          Ultimately, I'm trying to find a workflow that allows for isolating chunks of the project to be worked on one at a time but the basic solo feature is a bit. After doing a bit more research it looks like layers is the way to go. When using layers the solo feature hides the other layers in the viewport and the object manager. If the original idea is still possible I'd be interested, simply because I think it would be a bit more frictionless (no need to add object to layers, soloing tied to object hierarchy, workspaces inside of workspaces). But I understand it's a strange request. I'm comfortable using the standard layers and soloing features for now.

          Cheers,
          Leo

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

            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

            Result

            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()
            

            MAXON SDK Specialist
            developers.maxon.net

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