Need help creating a non-modal dialog the can accept a drag and drop property reference
-
I've noticed that when you drag an object's property label (for example, the segments Y of a cube object) into the python Script Manager window, it makes a reference to the object and property - Cube[c4d.PRIM_CUBE_SUBY].
I'm trying to get a link to this property reference so I can reference it elsewhere. Ideally, I'd like to have a non-modal dialog pop up that allows me to drag and drop this property label onto it, and then send that reference elsewhere. Is this something that could be possible?
So far I've created a non-modal dialogue with a multiline text input box, but when I drag the property reference into it, all it displays is a generic reference to the property (PRIM_CUBE_SUBY vs. Cube[c4d.PRIM_CUBE_SUBY] that I want). How would I get the window to grab the whole reference. And even better, how could I make this a drag and drop window that prints that reference to the console (instead of a text box).
-
Hello @fkenned1,
Welcome to the Plugin Café forum and the Cinema 4D development 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 Guidelines, as they line out details about the Maxon SDK Group support procedures. Of special importance are:
- Support Procedures: Scope of Support: Lines out the things we will do and what we will not do.
- Support Procedures: Confidential Data: Most questions should be accompanied by code but code cannot always be shared publicly. This section explains how to share code confidentially with Maxon.
- Forum Structure and Features: Lines out how the forum works.
- Structure of a Question: Lines out how to ask a good technical question. It is not mandatory to follow this exactly, but you follow the idea of keeping things short and mentioning your primary question in a clear manner.
About your First Question
Your question is a little bit ambiguous, and I am not quite sure what you want to be done here.
- To get something simple out of the way: Cinema 4D
C4DAtom
instances, the atomic type all classic API scene elements derive from, have parameters which are indexed by c4d.DescID keys. Cinema 4D does not have properties in its classic API model. I understood what you meant, just as an FYI.- This is represented by the methods C4DAtom.GetParameter and .SetParameter.
- The methods GeListNode.__getitem__ and .__setitem__, i.e., the bracket syntax in
Cube[c4d.PRIM_CUBE_SUBY]
, are just convenience wrappers around theC4DAtom
methods. - The parameter keys passed to these methods are internally always
c4d.DescID
, it is only the convenience methods__get/setitem__
which allow you to pass integers instead, e.g., writeCube[c4d.PRIM_CUBE_LEN,c4d.VECTOR_X]
orCube[1100, 1000]
(both do the same). - I went over the subject of parameter IDs in more detail here.
- The drag and drop behavior of the Python console is proprietary and not exposed, I also do not quite understand what you want to do with it inside a dialog.
- If you want to let a user reference an object in a dialog, as for example many objects do in Cinema 4D, you must use a
BaseLink
parameter. In dialogs you can do this with theCUSTOMGUI_LINKBOX
custom gui. I have shown here how to do this.
Letting a user reference a parameter in this manner is not possible. You could technically unpack parameter drag data (at least in C++, likely not in Python, have not checked though) to get hold of a dragged
BaseList2D
and traverse its description (possible in C++ and Python) of a node to figure out to whichDescID
for example the string"c4d.PRIM_CUBE_LEN, c4d.VECTOR_X"
corresponds to. But I do not quite understand the purpose of all this? I am sure there is a less complicated way to achieve what you want to do.I would recommend sharing your code and explaining what you want to achieve on a high level, as the workflow you have in mind is either impossible or at least very labor intensive to implement.
Cheers,
Ferdinand