handling advanced selection in a tool

handling advanced selection in a tool

Postby ittayd » Mon Jun 12, 2017 8:02 am

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.
0

ittayd 
 

Re: handling advanced selection in a tool

Postby ittayd » Mon Jun 12, 2017 8:05 am

Just found Sketchup.send_action. Will try to explore it.
0

ittayd 
 

Re: handling advanced selection in a tool

Postby ittayd » Mon Jun 12, 2017 3:49 pm

So send_action is async, so the code that calls it returns immediately
0

ittayd 
 

Re: handling advanced selection in a tool

Postby Dan Rathbun » Mon Jun 12, 2017 7:27 pm

ittayd wrote:Is there a way to utilize sketchup's own selection tool?

The only way is to attach a SelectionObserver, activate SketchUp's native SelectTool Sketchup.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.

http://www.thomthom.net/thoughts/2013/01/pickhelper-a-visual-guide/



Other than that, you best learn by reading the example extension by the SketchUp Team (EW) or others like ThomThom's plugins.
0
    I'm not here much anymore. But a PM will fire email notifications.
    User avatar
    Dan Rathbun 
    PluginStore Author
    PluginStore Author
     

    SketchUcation One-Liner Adverts

    by Ad Machine » 5 minutes ago



    Ad Machine 
    Robot
     



     

    Return to Developers' Forum

    Who is online

    Users browsing this forum: No registered users and 3 guests

    Visit our sponsors: