Hi,
@gsmetzer said in Drag and Drop onto Range Slider:
I just want to get the object data from the object that is dropped on the slider. Thats about as simple as I can say it.
It looks as though you can't pass any DRAG AND DROP message from the Range Slider.
check = op[c4d.ID_USERDATA, 1].Message(c4d.MSG_DRAGANDDROP)
Console: AttributeError: 'c4d.RangeData' object has no attribute 'Message'
but works for a link object like you said earlier.
Is there maybe a way to draw a GeUserArea with a drop area over the Range Slider?
c4d.C4DAtom.Message()
is a method of the atomic type of c4d -c4d.C4DAtom
. So you can only invoke it on types that are deriving from that type. Most types that are presented in GUI elements are not derived from C4dAtom
(e.g. float, int, bool, str, c4d.Vector, c4d.SplineData, c4d.RangeData
, etc.). This is the reason why you get the exception: RangeData
is not derived from c4d.C4DAtom
, while a BaseList2D
(the type objects are collected under in the object link GUIs) is derived from it.
But there is also another misunderstanding. You do not have to invoke Message()
yourself , but Cinema does it for you. And Message()
is also invoked on the C4DAtom
that is hosting the description that drag and drop event has occurred on, not on its data elements (for the reasons described above). You can then listen to that message in the implementation of your atoms Message()
method - or message()
function in case of a scripting object - as shown above. Here is a more complete example, for your case of a Python generator object:
import c4d
# Put this in a Python generator and drag and drop stuff onto that generator's description elements,
# i.e. stuff in the attribute manager.
def main():
return c4d.BaseObject(c4d.Ocube)
def message(mid, data):
if mid == c4d.MSG_DRAGANDDROP:
print mid, data
The drag and drop event also sends its drag and drop data, but it is a PyCObject
, which is of no use to us, since it is only a pointer to the C(++) data structure of that drag and drop data. So to properly react to drag and drop events in Python, we only can deal with drag and drop events of data that matches the data type of the gadget/element it is dropped onto. Since we then can either just compare the (cached) previous value and the new current value or just deal with the current value.
I hope this helps.
edit: While GeUserArea
also offers a Message()
method, you cannot use it. Because GeUserAreas
are for dialog resources and not description resources. Everything displayed in the attribute manager has a description resource (with ToolData
being an exception). You also cannot place / draw stuff on top of each other in general in c4d.
Cheers
zipit