Use the tab name and open the that window?
-
Use the tab name, Open that window?
Can I use the tab name and open that window?
I want to switch the Viewports and Project Settings windows to Python.
Access to tabs in the SDK is rarely written.
Asking for help. Thank You. -
Hello @ymoon,
thank you for reaching out to us. Neither the Python nor C++ Cinema 4D API do not provide control over existing/native window and dialog elements of Cinema 4D. You have only access to the things you have implemented yourself. This is an intentional decision and not a feature gap.
In the Cinema 4D API, you do not have control over the active tabs in a layout. What you can do is:
- Load a layout: This will also include the saved activation state of tabs in the layout.
- Display scene elements in a description GUI: While you cannot influence the UI of Cinema 4D, you can display the data this UI is exposing in many cases. Most things are nodes these days in Cinema 4D, this also applies to the project settings. In the example I have shown this for the user preferences, but it would work the same for the document settings. Note that there are certain limitations to what can be done with the
DescriptionCutomGUI
in Python, other than in C++, setting the active tab is not possible. - Use ActiveObjectManager_SetMode/4d.gui.ActiveObjectManager_SetObject: The Attribute Manager makes some exceptions to the no-GUI-interaction rule. In the C++ API, there is a method called
ActiveObjectManager_SetMode
with which you can switch the mode of the Attribute Manager. It has no direct equivalent in Python, but you can emulate is functionality with this code:
"""Opens the projects settings in the Attribute Manager. """ import c4d def main() -> None: """ """ c4d.gui.ActiveObjectManager_SetObject( c4d.ACTIVEOBJECTMODE_DOCUMENT, # The mode to set, the document mode herel. c4d.BaseList2D(c4d.Onull), # A dummy object which does not matter in this case, # because there is only one relevant document node. c4d.ACTIVEOBJECTMANAGER_SETOBJECTS_OPEN # Open a new AM if there is none open. ) c4d.EventAdd() if __name__ == '__main__': main()
Cheers,
FerdinandPS: Please state your used version of Cinema 4D in the future when it is not the most recent one.
-
@ferdinand
There is no command to invoke the viewport window, so I was looking for an alternative. I will tagging the version in the next post. (R2023) Thank You.