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

    Drag&Drop in Editor window

    Cinema 4D SDK
    r20 python
    2
    3
    517
    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.
    • P
      pim
      last edited by

      I have taken the EditorWindow.MouseDragStart() example from the manual and it works well in a flat view.
      In perspective view the z coordinate is a bit strange, although I set it to 0.

      What am I doing wrong?

              obj = doc.GetActiveObject()
              mousex = msg[c4d.BFM_INPUT_X]
              mousey = msg[c4d.BFM_INPUT_Y]
      
              win.MouseDragStart(c4d.KEY_MLEFT, mousex, mousey, c4d.MOUSEDRAGFLAGS_DONTHIDEMOUSE|c4d.MOUSEDRAGFLAGS_NOMOVE)
      
              mx = mousex
              my = mousey
              while True:
                  result, dx, dy, channels = win.MouseDrag()
                  if result!=c4d.MOUSEDRAGRESULT_CONTINUE: break
                  mx += dx
                  my += dy
      
                  coord = bd.SW(c4d.Vector(mx,my, 0))
                  obj[c4d.ID_BASEOBJECT_REL_POSITION] = coord
      
      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by

        Hi @pim, a dragging session only occurs in a 2D space (your screen, the viewport is a 2D representation of a 3D spaces).
        So retrieving such a Z coordinate don't make a lot of sense.
        If you want to retrieves the Z coordinate, you need to cast a ray in order to calculate intersections to retrieves a Z component but using the ViewPortSelect class could also help you, may ask you why you need to retrieve it?

        Please help us to help you by providing as much as possible information (the more we know the context the more precise we can answers)

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 1
        • P
          pim
          last edited by

          Yes - dragging session only occurs in a 2D space - I thought so.
          Thanks.

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