What what what? This makes no sense!
-
Save the following snippet into a test module in your plugins folder.
Draw some shapes in SU and select everything. (have some groups/comps)
def self.test model = Sketchup.active_model ents = model.selection.to_a arr = [] until ents.empty? e = ents.shift next unless e.is_a?(Sketchup;;Edge) arr << e.all_connected.to_a.select{ |entity| entity.is_a?(Sketchup;;Edge) } end arr.length end
When you run the snippet, which does nothing but create some arrays, the loose geometry appears to deselect. But they are in fact selected, which the Entity Info displays. You can even use the move tool for instance and see that everything is moved.
It all boils down to this line:
arr << e.all_connected.to_a.select{ |entity| entity.is_a?(Sketchup::Edge) }
But why? It makes no sense.
I see this on SU 7.1, Windows and OSX. It's maddening! -
I slimmed it down further:
def self.test model = Sketchup.active_model ents = model.selection.to_a e = ents.shift e.all_connected end
If you have three separate squares in your model selected when you run this, then one will appear to be unselected afterwards.
-
Glitch in the API somewhere - until it's fixed perhaps you can add
model.selection.add(ents)
near the end to ensure the original selection stays highlighted ? -
@tig said:
Glitch in the API somewhere - until it's fixed perhaps you can add
model.selection.add(ents)
near the end to ensure the original selection stays highlighted ?.add and .remove are just aliases for .toggle
@thomthom said:
I slimmed it down further:
So did I, the culprit is the .all_connected methods for Face and Edge classes.
module Select_Test def self.go model = Sketchup.active_model view = model.active_view sel = model.selection sfc = sel.first.all_connected view.refresh # the first square unhilites UI.messagebox('Ready to Re-Hilite the square.') sel.toggle sfc # removes from the selection sel.toggle sfc # adds back into selection view.refresh # the first square REhilites end end # module
P.S.: I AVOID using "test" as a method name because of the importance of Kernel.test which all objects inherit.
-
@thomthom, is this still a bug, or has it been fixed ?
-
hm...
I don't recall this thread at all any more. But I tried this in SU2016, and it seem to be doing something odd. In my test a group would be deselected after running this code and making a zoom to update the viewport.
Advertisement