Using / copying object properties dialog
-
Sorry for the cryptic title, but I want to copy / use a part of a standard object attributes dialog.
For example, I want to copy / use the Caps settings of an Extrude Object in my python code.Is that possible?
-
Hello @pim,
Thank you for reaching out to us. There are some things which are not clear to me in your question, but I mostly understand what you want to do.
- The file-based definition of a GUI is called a resource in Cinema 4D. There are description and dialog resources. All
NodeData
based plugin hooks use descriptions as their GUI, so the Extrude object has a description, and not a dialog. - You do not clarify how you want to "copy/use" the settings and there is no general copy mechanism. But there are includes, as certain aspects of descriptions are defined separately, so that multiple entities can load them in, the "Basic" tab for objects, interpolation settings for spline, and also the "Caps" tab. When we look at the Extrude object description, we can see how this works.
CONTAINER Oextrude { NAME Oextrude; INCLUDE Obase; // Loads in the "Basic" properties shared by all Obase plugins. INCLUDE Onurbscaps; // Loads in the "Caps" tab used by all plugins which have caps. INCLUDE Onurbsselection; // Loads in the "Selections" tab. // Start of the custom defintions of the Oextrude ... GROUP ID_OBJECTPROPERTIES { LONG EXTRUDEOBJECT_DIRECTION { ... }
- When you mean copying in a more abstract sense, we talked about this subject here.
Cheers,
Ferdinand - The file-based definition of a GUI is called a resource in Cinema 4D. There are description and dialog resources. All
-
@ferdinand
Your option 2 is what I meant, but then how can I use that in my pyhon CreateLayout() code.
The thing is that - it seems to me - the interface / the discription is already there, why not re-use it?Sorry to be unclear.
Pim -
Hey @pim,
well, you can re-use things with
INCLUDE
, you can in fact reuse any description which has been registered. You could for example base yourObjectData
plugin on the Cube object by including Ocube.But, as explained in my first answer:
The file-based definition of a GUI is called a resource in Cinema 4D. There are description and dialog resources. All
NodeData
based plugin hooks use descriptions as their GUI, so the Extrude object has a description, and not a dialog.This collides with the following statement of yours.
Your option 2 is what I meant, but then how can I use that in my pyhon CreateLayout() code. The thing is that - it seems to me - the interface / the discription is already there, why not re-use it?
GeDialog.CreateLayout
is tied to dialog resources and with GeDialog.LoadDialogResource you can load in such resources. You can in fact chain together multipleLoadDialogResource
calls to assemble a GUI from multiple dialog resources, each call will append to the result of the last call (more advanced techniques which manipulate the insertion pointer aside).The Extrude object is however a node and not a dialog, it is therefore based on description resources and not dialog resources. Although the resources might look similar in syntax, they are not identical. You cannot reuse the nurbs
Caps
tab in dialog, because the resource is for descriptions.The following manuals can be found in the C++ documentation, but their content is also directly applicable to Python:
- Resource Files Manual: Provides a general overview for the concept of resources.
- Dialog Resources Manual: Describes the resource syntax used by dialogs.
- Description Resources Manual: Describes the resource syntax used by nodes.
When you are determined to do this, there is one thing you could do. Implement a node
MyNode
to define a description-based GUI and includeOnurbscaps
. Then implement a dialog, add aCUSTOMGUI_DESCRIPTION
to dialog, instantiateMyNode
, and display it in theCUSTOMGUI_DESCRIPTION
. I.e., if you want to, you can display descriptions inside a dialog. This is effectively how things like the Attribute Manager, the User Preferences, or the Render Settings dialog work. But it seems like a bit overkill in your case. I would just recreate these settings.Cheers,
Ferdinand -
Thanks for the clear answer.
I know the difference between description and dialog, but I was hoping I could re-use already defined description in a dialog.
But I follow your advise and recreate the settings.Regards,
Pim