How to speed up Sketchup user scripts

asked 2017-12-02 22:03:44 -0500

TomB's avatar

updated 2017-12-05 15:17:35 -0500

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
edit retag flag offensive close merge delete

Comments

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?

Julien Marrec's avatar Julien Marrec  ( 2017-12-05 09:25:46 -0500 )edit
1

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.

Julien Marrec's avatar Julien Marrec  ( 2017-12-05 09:32:15 -0500 )edit