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

    GetDragObject always returning exception

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 292 Views
    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.
    • H Offline
      Helper
      last edited by

      On 02/08/2016 at 02:38, xxxxxxxx wrote:

      I'm trying to detect what type of object is being dragged into a LINK gizmo, inside a dialog defined by a res file.

      I'm using the code:

        
      def Message(self, msg, result) :   
           if msg.GetId() == c4d.MSG_DESCRIPTION_CHECKDRAGANDDROP:   
                try:   
                     obj=self.GetDragObject(msg)   
                except:   
                     return gui.GeDialog.Message(self, msg, result)   
        
                print obj   
        
           return gui.GeDialog.Message(self, msg, result)   
      

      But the print obj is never reached.
      I'm not even sure if I'm using the GetDragObject() command correctly because it is not documented in the Python SDK.

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 02/08/2016 at 09:54, xxxxxxxx wrote:

        Whenever I place questions here, I don't stop trying to search for ways to solve my problems and get results.
        So, here is what I have come up with:

          
        def Message(self, msg, result) :   
             if msg.GetId() == c4d.BFM_DRAGRECEIVE:   
                  # check if the dragging operation is into my LINK gizmo   
                  if self.CheckDropArea(MY_LINK_GIZMO,msg,True,True)==True:   
                       # get the drag information   
                       draginfo=self.GetDragObject(msg)   
                       # get the list of objects dragged   
                       obj=draginfo['object']   
                       # in my case, I just allow one   
                       if len(obj)==1:   
                            # if it is the allowed type, happily return   
                            if obj[0].GetType()==ALLOWED_ID: return gui.GeDialog.Message(self, msg, result)   
                       # otherwise, signal that is not allowed   
                       return self.SetDragDestination(c4d.MOUSE_FORBIDDEN)   
          
             return gui.GeDialog.Message(self, msg, result)   
        
        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 03/08/2016 at 05:09, xxxxxxxx wrote:

          Hi Rui,

          just want to acknowledge reacting on BFM_DRAGRECEIVE message is the correct approach.

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