Highlight each instance in a selection set
-
Hello!
I'm building a selection set and would like to view every component instance, one by one, in the selection.ss = Sketchup.active_model.selection ss.each do |e| if( e.kind_of? Sketchup;;ComponentInstance ) ...
What can I insert in the "do" loop operation in order to visualy highlight every instance?
Thanks for your help!
-
ss = Sketchup.active_model.selection.collect ss.each do |e| if( e.kind_of? Sketchup;;ComponentInstance ) Sketchup.active_model.selection.clear Sketchup.active_model.selection.add e UI.messagebox("Next") end end
-
Thanks Jim!
Once again, you hit the mark.
First, I missed the ".collect" and get a bug on sketchup.Have you got any idea what scan order is prefered in the 'do' loop?
Any way to sort the collection? -
@unknownuser said:
Thanks Jim!
Once again, you hit the mark.
First, I missed the ".collect" and get a bug on sketchup.Have you got any idea what scan order is prefered in the 'do' loop?
Any way to sort the collection?Collect is a Ruby method that just makes a copy of the selections in an Array.
There isn't any order to the entities returned (that I am aware of.) You'll need to sort them manually, possibly by building another array of only the instances. Then, you'll need to decide what to sort on: definition name, color, position, size?
Advertisement