Got it to work. Thanks, TIG!
@tig said:
You can use some simple 'one-liners' in the Ruby Console...
I'll explain the parts, then assemble them into a single line you can copy/paste into the Ruby Console, editing the component name 'cn'...
You need to manually make the layer and assign the selected component instances to it...
That process could also be included if you like...
cn="^Wall"
the component-definition's name pattern.
note that "Wall" selects just wall, "^Wall" selects all starting with Wall, "^[Ww]all" includes those starting with upper and lower-case W, "^Wall[0-9]" limits it to those named Wall + a number 0 to 9 [and anything following]. To end a pattern use a final $ - so "^Wall[0-9]$" would NOT then match "Wall01" !
Edit this string to suit your needs...
m=Sketchup.active_model
ss=m.selection
ss.clear
as=m.active_entities
cs=as.grep(Sketchup::ComponentInstance).find_all{|e|e.definition.name=~/#{cn}/}
ss.add(cs)
And in just one line:
cn="^Wall";m=Sketchup.active_model;ss=m.selection;ss.clear;as=m.active_entities;cs=as.grep(Sketchup;;ComponentInstance).find_all{|e|e.definition.name=~/#{cn}/};ss.add(cs)