Drag&Drop in Editor window
-
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
-
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. -
Yes - dragging session only occurs in a 2D space - I thought so.
Thanks.