Ruby How to Select All Connected
-
Hello Forum,
There is a right-click option called "select all connected".
is it also possible with ruby?Thank you
-
Yes, you use the edge method
http://code.google.com/apis/sketchup/docs/ourdoc/edge.html#all_connected
or face method
http://code.google.com/apis/sketchup/docs/ourdoc/face.html#all_connected
to get an array of the connected edges/faces.
e.g. assume we have reference to an 'edge'
all = edge.all_connected model.selection.add(all)
To find a list of just all connected edges you could filter the array to ignore faces etc... -
Have look at this plugin:
http://forums.sketchucation.com/viewtopic.php?t=14975 -
Thank you very much. It works,
but i'ts not exacty what I need.So I should have changed the question a bit.
I need to select (all) connected edges to an accurve (created between to edges with Fillet.rb)
Additionally the selection should not go to further edges or anything, only the two edges and the arccurve.
So all_connected() wont work.(All this is for automatically handing them (the path) over to PipeAlongPath.rb)
-
If you are asking about ruby methods in order to write your own plugin, I'd rather move the topic to the developers forum. I will definitely not be able to help in this area...
-
I've moved this into the Developers' Forum as it's a general issue...
You can get info about a curve.
verts=curve.vertices
returns the vertices, so if it's an arc etc thenvf=verts.first
andvl=verts.last
are the end vertices.
You can also get the start and end edges withef=curve.first_edge
andel=curve.last_edges
You can get the edges that use any vertex with
edges=vertex.edges
so do that forvf
andvl
in turn - the array of edges will include the curve's edge sofedges=vf.edges; fedges.delete(ef); fedgeyouwant=fedges[0]
ditto forvl
/el
So you now have a way to find the two edges connected to ends of an curve.
This assumes you have checked it's a curve, it's not looped etc; and if there isn't a connected edge you get 'nil'. or if there are more than connected edge then only the first one found is returned...
Advertisement