Can we handle drag document from treeview?
-
Hi community,
I have a treeview and list some c4d files, I want to drag it and open or merge it rather than double-click, but I didn't find the right setup, how can I do this?
Thanks for your time.
Cheers~
DunHouCodes about this
def GetDragType(self, root, userdata, obj: TreeViewBaseObject): # if the object representing a c4d file, but scene seems not the right opotion if obj.filetype == "c4d": return c4d.DRAGTYPE_ATOMARRAY # c4d.DRAGTYPE_FILENAME_SCENE return c4d.DRAGTYPE_ATOMARRAY def GenerateDragArray(self, root, userdata, obj: TreeViewBaseObject): if obj.filetype == "c4d": #c4d_file = c4d.documents.LoadDocument(obj.path, c4d.SCENEFILTER_NONE) elements = [obj.path] return elements
-
Hi @Dunhou,
Please excuse the delay in providing the answer.
If I get you right, you have a treeview gadget that is populated with some items representing paths to the c4d document files and your intention is to be able to drag and drop these entries into cinema to make them open/merge (similar behavior as files were dragged and dropped from the Explorer), is that right?
The GenerateDragArray() is used when GetDragType() returns c4d.DRAGTYPE_ATOMARRAY. In your case you would need to use c4d.DRAGTYPE_FILES or c4d.DRAGTYPE_FILENAME_SCENE instead of c4d.DRAGTYPE_ATOMARRAY. This also requires using GenerateDragData() function instead of GenerateDragArray(). However, the GenerateDragData() function is only available in C++ at the moment, so you would need to use C++ SDK to make this work. This can hopefully be fixed in future releases but I don't have any time estimates about that.
Cheers,
Ilia -
Hi @i_mazlov ,
Sadly the GenerateDragData() not work in python, I had try the c4d.DRAGTYPE_FILENAME_SCENE, but it will return bad without GenerateDragData(),seems nothing we can do here.
Cheers~
DunHou