Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Can we handle drag document from treeview?

    Cinema 4D SDK
    windows python 2024
    2
    3
    559
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DunhouD
      Dunhou
      last edited by

      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~
      DunHou

      Codes 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
      

      https://boghma.com
      https://github.com/DunHouGo

      i_mazlovI 1 Reply Last reply Reply Quote 0
      • i_mazlovI
        i_mazlov @Dunhou
        last edited by

        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

        MAXON SDK Specialist
        developers.maxon.net

        DunhouD 1 Reply Last reply Reply Quote 0
        • DunhouD
          Dunhou @i_mazlov
          last edited by

          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

          https://boghma.com
          https://github.com/DunHouGo

          1 Reply Last reply Reply Quote 0
          • First post
            Last post