Handling advanced selection in a tool
-
I'm writing a tool in which I want a first step, then a step to allow the user to pick several entities and then more steps to manipulate them.
The problem is how do I allow the user to select the entities? I tried handling entity and window selection with PickHandler, then added modifier keys handling for add/remove/toggle, now I'm about to handle open & close of groups... It just seems too cumbersome.
Is there a way to utilize sketchup's own selection tool? So the user starts my tool, selects entities using the usual way and then gets back to my tool for the next steps. I can try reorganizing the tool so it expects a selection when it starts, but I want to see if I can do things the way I want.
-
Just found Sketchup.send_action. Will try to explore it.
-
So send_action is async, so the code that calls it returns immediately
-
@ittayd said:
Is there a way to utilize sketchup's own selection tool?
The only way is to attach a
SelectionObserver
, activate SketchUp's native SelectToolSketchup.active_model.select_tool(nil)
, collect the object references, detach the observer, and activate your tool.But trying to leverage native tools via code has been problematic in the past. So, this is why they finally added (SU2016) the two window pick methods to the
PickHelper
class.ThomThom wrote a tutorial and created a graphic helper chart for using this class.
PickHelper — A Visual Guide
I’ve put together a visual guide to the PickHelper class in SketchUp’s Ruby API. When I first tried to use the PickHelper class I was confused over what the different methods did, and f…
Procrastinators Revolt! (www.thomthom.net)
Other than that, you best learn by reading the example extension by the SketchUp Team (EW) or others like ThomThom's plugins.
Advertisement