Is there an equivalent in Ruby to “Select All” (Cmd-A)?
I want to hide everything that is visible in my current scene, after the user has picked a selection set to be processed.
Is there an equivalent in Ruby to “Select All” (Cmd-A)?
I want to hide everything that is visible in my current scene, after the user has picked a selection set to be processed.
https://forums.sketchup.com/t/is-there-a-way-to-select-everything-in-the-model/190276?u=dezmo
BTW.
You do not need to add entities ( Drawingelement ) to selection if you just want to make it #hidden.
Thank you! I did search but couldn’t find anything that fitted.
I have nearly completed my first plugin.
if Sketchup.platform == :platform_osx
Sketchup.send_action('selectAll:')
else # win
Sketchup.send_action(21101)
end
To hide what is selected:
Sketchup.send_action('editHide:')
REF:
Thanks Dan, I took on @dezmo solution as I need to save the selection set (selEE), hide, process a different set and then restore (selEE) on completion. Everything seems to work so far, but I am new to this so my coding may not be entirely efficient.
model = Sketchup.active_model
entities = model.active_entities
selection = model.selection
selection.add(entities.to_a)
selEE = Sketchup.active_model.selection.grep(Sketchup::Entity)
Ironically, although it works ‘selectAll:’ is not listed on the page you linked!
That snippet is a bit weird. First of all, since the selection can’t contain anything except Entities, there is nothing accomplished by grepping it for them! But also, unless you need them selected for some other use, adding them all to the selection just wastes time; just process the active_entities directly using to_a.
Yes, I know. (It has been said by thomthom [I think] that that method is low priority, and they’d rather have direct methods to do many of these actions.)
I got it from a text file on Mac menu commands (that I think John Boundy gave me.)
Not all of them are cross-platform, but many are.