Automatic extraction of edges?


#1

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?

Thanks,

Dan


#2

Hi Dan,

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).


#3

Hi Dan,

I think rs.DuplicateEdgeCurves() or rs.DuplicateSurfaceBorder() might do what you want - assuming you actually want the edges added to the document.

–Mitch


#4

Hi @djordje,

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! :smiley:

Dan


#5

Yes, I think I’m wrapping my head around this. You know the saying about “teach a man to fish, and you feed him for life”? I think I’m fishing now! :wink:

Dan


#6

I think they’re biting for for you today… :fish: :tropical_fish: :whale:

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.

–Mitch


(Willem Derks) #7

Hi Dan,

Yesterday after posting my reply in the other topic, I was thinking on how to approach this.
How about this:

Intersect the object with an XYplane through it’s boundingbox center.

  • It will get you all the curves with 100% certainty parallel to the XYplane.
  • composed top surfaces will not be an issue (eg 2 joined surfaces in the top)
  • possibly tolerance issues with edges can be avoided
  • you have all the curves you need in one shot

Just a thought…I’l go back to not procrastinating now

-Willem


#8

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.

Dan


(Willem Derks) #9

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.

Cheers
-Willem