JBenghiat Posted April 4, 2023 Share Posted April 4, 2023 Is there a way to figure out when dragging an object is complete, and get the location of where the user released the mouse? On first review, the only way I can see to do this is store the cursor location during OnDrag() to a static variable, and then on object move check if that variable has data -- but that seems a little tedious. Quote Link to comment
Hippocode Posted April 8, 2023 Share Posted April 8, 2023 (edited) I think that is exactly what you should do. I'm using this in one of my tools in "OnDrag()" and it does the job. Quote WorldPt3 CurrentPoint; gSDK->GetToolPtCurrent3D(CurrentPoint); WorldPt3 DragOrigin; gSDK->GetToolPt3D(0, DragOrigin); WorldPt3 DraggingOffset = CurrentPoint - DragOrigin; WorldPt3 DraggingDirection = DraggingOffset; DraggingDirection.Normalize(); DraggingOffset.z += (WorldCoord) Utility::GetLayerElevation(); Edited April 8, 2023 by Hippocode Quote Link to comment
JBenghiat Posted April 11, 2023 Author Share Posted April 11, 2023 @Hippocode I’m just curious where you’re storing the cursor values so you can retrieve it after the event, especially when multiple objects are selected. A custom parameter seems like the easiest option, but that seems like a lot of overhead. Quote Link to comment
Hippocode Posted April 11, 2023 Share Posted April 11, 2023 2 hours ago, JBenghiat said: @Hippocode I’m just curious where you’re storing the cursor values so you can retrieve it after the event, especially when multiple objects are selected. A custom parameter seems like the easiest option, but that seems like a lot of overhead. In my case it was stored within the drag event sink itself, I believe you are trying something different. I would guess these two options could be useful? - Using "VWDataSerializerSimple" class to store the data directly into the object. I'm using this more and more because it's less work to maintain compared to records and fields. - In case the value is unique you could also store in permanent memory by using a VCOMImmediateImpl<IVWSingletonUnknown> interface. You could import/export into a custom interface which is accessible during the full execution of Vectorworks. Remember to handle document changes etc if you go this route. Quote Link to comment
Sam Jones Posted April 11, 2023 Share Posted April 11, 2023 15 minutes ago, Hippocode said: Using "VWDataSerializerSimple" class to store the data directly into the object. I'm using this more and more because it's less work to maintain compared to records and fields. Where is this class? How do I access this class? How do I store data in a (this) class? TIA! Quote Link to comment
Pat Stanford Posted April 11, 2023 Share Posted April 11, 2023 In the SDK Sam, In the SDK. Power such as that is not of us mere mortals. 😉 1 Quote Link to comment
Hippocode Posted April 11, 2023 Share Posted April 11, 2023 May the Force be with you. 🤖 Quote Link to comment
JBenghiat Posted April 11, 2023 Author Share Posted April 11, 2023 I think I might have a different solution. In the move state event, if the object has been dragged, gSDK->ClickDragToolStatus() returns kToolCompleted, otherwise, it returns kToolWaitingForFirstPoint. ISDK::GetToolPtCurrent3D() seems to be correctly returning the coordinates of the mouse-up, which then lets you calculate the transformation offset and ignore ObjectStateData_Position::fTransformOffset. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.