Trying to find polysurface edge lengths

Hello all,
I am trying to find an easy way to determine the lengths of all edges of a given polysurface but I have hit some roadblocks. A sample code is as follows:

import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc

obj = rs.GetObject('Select object to determine edge lengths', preselect=True, select=True)
geo = sc.doc.Objects.Find(obj)
for i, edge in enumerate(geo.Geometry.Edges):
    xC = (edge.PointAtEnd.X + edge.PointAtStart.X)/2
    yC = (edge.PointAtEnd.Y + edge.PointAtStart.Y)/2
    zC = (edge.PointAtEnd.Z + edge.PointAtStart.Z)/2
    rs.AddTextDot(str(edge.Domain.Length)[:5], [xC, yC, zC])

This will create a text dot at the center of each polysurface edge of that edge’s domain length (as given from scriptcontext via Geometry.Edges[#].Domain.Length. My problem is that this length is inaccurate, compare the 14.25" length edges to the 13 1/2" overall dimension:


(some text dots removed to make the geometry easier to see)

Does anyone have any insight into what this “Domain” is actually referencing, or other factors that alter the lengths, such as trimmed edges? It is simple enough to calculate a distance between the points at start and end to find the length, since those are accurate, but I’m hoping to find a solution that will account for curved edges. Any ideas?

Hi,

You could try edge.GetLength() instead.
Domain refers to the curve domain of the edge in question. A curve has for instance a domain of (0.0, 15.2) or (9.7, 27.8). The domain length is computed by subtracting the domain start from the domain end (e.g. 27.8 - 9.7 = 18.1).

1 Like

Excellent, that worked perfectly!
Thanks for your quick reply.

1 Like