If I want to create a list of edges, I currently call up the DupEdge command within my script, then window select over the surface. This will get me a list of edges. It would be much slicker if I could pick the surface (anywhere) and create that list of edges. Is this possible? If I use the GetEdgeCurves method, I still need to pick the edges manually (from what I can tell).
I guess what I’m searching for is functionality that will return all the edges of an object, not just the one you pick. Does this exist?
You can convert your surface to brep, and then extract the Edges out of it:
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
brep_id = rs.GetObject("pick up your surface")
brep = rs.coercebrep(brep_id)
edges = brep.Edges
duplEdgs = [edg.DuplicateCurve() for edg in edges]
duplEdgs = Rhino.Geometry.Curve.JoinCurves(duplEdgs)
edges_id = [sc.doc.Objects.AddCurve(edg.DuplicateCurve()) for edg in duplEdgs]
Comment out the next-to-last line in case you do not want the extracted edges to be joined (if possible).
I think I’m getting it now. I actually came up with something somewhat similar myself:
object = rs.GetObject(“Select anywhere on the base plate”)
brep_obj = rs.coercebrep(object)
crvs = Rhino.Geometry.Brep.DuplicateEdgeCurves(brep_obj)
for crv in crvs:
curve = rs.coercecurve(crv)
if rs.IsArc(curve):
pt = rs.ArcCenterPoint(curve)
diameter = (rs.ArcRadius(curve) * 2)
rs.AddPoint(pt)
print diameter
The last example you gave me (about extracting the surface) pointed me in the right direction.
Thanks for your help. I think this was a very productive day for me as far as progressing with Python and Rhino. There should be less questions tomorrow!
Anyway djordje’s method via RhinoCommon is better if you don’t want to add the curves to the document, but rather just extract info from them or use them for something else.
Willem, I will archive your suggestion. I’ve got my issue solved, but your suggestion may be useful in the future.
I appreciate everyone’s help, thank you.
Sure,
I just wanted to share it as the thought was already thought and else it would have just stayed in my head.
Good you have it sorted out!
Just a couple of weeks ago I started to get working in Python and it has been great so far; constantly discovering new stuff.