Detecting Ctrl-[Move || Rotate]
-
Yo! Im trying to detect new entities added using the move or rotate tool while pressing Ctrl.
Using the Meta Observer i can see that the ToolObserver, SelectionObserver and some Transaction Callbacks are triggered, but I just cant figure out how to detect the new geometry (for some reason the EntitiesObserver doesn't trigger when Ctrl-move or rotate )
Can someone point me in the right direction?
Peace out
Pierre -
Before the Move or Rotate tool is used, the selection set will contain the "old" entities.
When the user completes the CTRL Move or CTRL Rotate, the selection set will contain the "new" entities.
Because the selection set changes, the onSelectionBulkChange callback in your Sketchup::SelectionObserver subclass instance should fire.
Within your custom SelectionObserver's onSelectionBulkChange callback, you can check what the active tool id is:
tool_id = Sketchup.active_model.tools.active_tool_id if tool_id == 21048 # The Move tool was used. elsif tool_id == 21129 # The Rotate tool was used. else # Some other tool was used. end
BUT if the user did not use CTRL, then the selection set will still contain the original entities (but their transform may have changed.) In this case the onSelectionBulkChange callback may not fire (so this could be how you can detect the difference between a normal Move and a CTRL+Move, as well as a normal Rotate and a CTRL+Rotate.)
-
Exception... after testing:
If the user does NOT preselect items using the SelectionTool, but instead selects ONE item using the MoveTool or RotateTool, then when the process is complete (regardless whether they use the tool in normal mode or CTRL copy mode,) the selection set will be empty, ie:
Sketchup.active_model.selection.count0
-
Awesome, thats exactly what i needed!
Have a great sunday!
Advertisement