Select component with ruby?
-
what's the code for selecting a component by name?
(or is there one?)ie- what exactly would I type into the console to select a component named "board"..
(and I realize it may require more than one line.. in the past, I've typed multiple lines in a text editor then copy/pasted into the console.. and it works ok.. is there a better way to do that if need be?)
gracias!
-
Sketchup.active_model.selection.add( Sketchup.active_model.definitions['board'].instances )
Note that this selects all instances in model - which might not be in the current context. Selections across context can make SketchUp behave oddly. Ye have been warned!
-
sweet.. thanks!
so far so good..
-
@unknownuser said:
in the past, I've typed multiple lines in a text editor then copy/pasted into the console.. and it works ok.. is there a better way to do that if need be?)
gracias!
hi Jeff,
did you know you can input multi-line scripts into 'Ruby Console' by using Alt/Return at the end of each typed line and then Return [on it's own] to enter/use it.
Also once somethings been entered you can re-use those same lines by toggling the up/down arrows to go back to a previously entered snip then hit return...john
-
@unknownuser said:
did you know you can input multi-line scripts into 'Ruby Console' by using Alt/Return at the end of each typed line and then Return [on it's own] to enter/use it.
Also once somethings been entered you can re-use those same lines by toggling the up/down arrows to go back to a previously entered snip then hit return...john
tip 1 -- thank you… that's good to know.. how about a way to type a long line with some sort of character in it indicating it's a new line..
somethinglikethis =
something
like
this?
tip 2
awesome. that's a good one too! -
@driven said:
did you know you can input multi-line scripts into 'Ruby Console' by using Alt/Return at the end of each typed line and then Return [on it's own] to enter/use it.
Only on OSX. Not on Windows.
@driven said:
Also once somethings been entered you can re-use those same lines by toggling the up/down arrows to go back to a previously entered snip then hit return...
This works on both platforms, but I think OSX is a little bit smarter. If you execute a command multiple times OSX it will merge them together onto one item in the history stack.
-
Of course adding a '
;
' into a line works as if it were a 'newline', needed in some code...
Soputs 123;puts 456;puts 789
in the one line is like typing the commands on three separate lines in turn... -
ruby will allow spanning lines with a
\
(in some cases.)
Advertisement