How to implement entity selection "wizard"
-
In Sketchup most of the tools contain a sort of "wizard" where the status line tells you what to pick and then when you pick it, what to pick next, etc. How can I do this in an extension?
-
@ittayd said:
In Sketchup most of the tools contain a sort of "wizard" where the status line tells you what to pick and then when you pick it, what to pick next, etc. How can I do this in an extension?
The set_status_text method is used to set the text appearing on the status bar within the drawing window.
If no arguments are passed, the status bar content is cleared. Valid positions are:
SB_PROMPT - the text will appear at the left-side of the status bar
SB_VCB_LABEL - the text will appear in place of the VCB label
SB_VCB_VALUE - the text will appear in the VCBSketchup.set_status_text "This is a Test", SB_VCB_VALUE
-
Thanks. And how do I pick elements one by one? Do I need to listen to mouse clicks or is there something that takes care of the flow for me?
-
You need to set up your Extensions as a 'Tool'.
http://ruby.sketchup.com/Sketchup/Tool.html
Clear the selection as you initialize.
On a mouse-click you use a pick-helper.
That filters what you have clicked on - so you can have various results.
You then filter that further by limiting what chosen by some other factor[s] like: context, already-selected, material, layer, name, attribute etc.
If you have a valid object add it to the selection.
Repeat until the user exits - e.g. double-click or <enter> press - then go onto the next step in your tool... -
... and new for SketchUp vers 2016 and higher is a rectangular window picking method:
http://ruby.sketchup.com/Sketchup/PickHelper.html#window_pick-instance_methodYou should download the SketchUp Team's Examples extension to see how Tools are written.
http://extensions.sketchup.com/en/content/example-ruby-scripts
Advertisement