How to speed up Sketchup user scripts
Is it possible to loop over the runner.selection in a Sketchup user script?
For example, to act on selected spaces only, the approach I have used is to loop over all spaces, checking if each is in the selection..
model.getSpaces().each do |space|
next if not runner.inSelection(space)
# do something to the selected space(s)
end
I want to speed this up, by only looping over the spaces that are in the selection. Is there something in the SDK that could allow this?
something like...
runner.inSelection().getSpaces.each do |space|
# do something to the space(s)
end
All of the official sketchup user scripts follow the same methodology you're currently employing, so I'd tend to say no. Is it really that slow? Big model?
I don't have sketchup to play with (on Linux right now), but pop open Sketchup's ruby console, and start with
Sketchup.active_model.selection
to see if you can find your spaces from this point.