Ruby selection
-
Hello forum,
I have a model which consists of faces and unconnected lines. How do I select the lines only using Ruby? I have attached an image file.
Thanks
-
First we set up some references.
model = Sketchup.active_model ss = model.selection
Then depending on how you want to 'start' off your plugin...
edges = model.active_entities.grep(Sketchup::Edge)
An array of all edges in the active context***OR
edges = ss.grep(Sketchup::Edge)
An array of all edges in the current selection.***Now resolve the selection:
ss.clear ss.add(edges)
***The 'rep' finds all edges, including those bordering faces.
So if you want to select just those edges without faces then you can extend the 'grep' code thus
... .grep(Sketchup::Edge).find_all{|e| e.faces.length == 0 }
The array 'edges' then just lists those edges without faces...
Advertisement