How to get the curves delimiting a trimmed surface?

My understanding of trimmed surfaces (from this post)is that they are defined by a surface and one or more curves that tell Rhino to hide some parts of the surface.

My question is, Is there a way to get the definition of those curves?

Dupedge seems to duplicate any edge of a surface, whether it is relimited by a curve or not. I want only the curves in the definition of the trimmed surface

Hi @julien.sibassie,

Surface and polysurfaces in Rhino, whether trimmed or untrimmed, are represented using the Brep data structure.

https://developer.rhino3d.com/api/rhinocommon/rhino.geometry.brep

Can you post a .3dm file and highlight the geometry you’re trying to access?

– Dale

Hello @dale ! Thank you for your answer.

My ultimate goal is to get the total number of control points that define a trim surface, both the control points of the surface and the trim curves. And to be able to script that in Python to get the total number of control points in a polysurface defined by an arbitrary number of surfaces and trimmed surfaces

Getting the total number of control points of the surfaces has been easy with rhinoscriptsyntax SurfacePointsCount but now I’m looking into a way to find the control points of the curves delimiting the trim surfaces.

The link you sent is interesting. From there I found the BrepTrim class that seems to be exactly what I am looking for.

I am now looking into how to use the Rhinocommon API in Python.

I think I found a way to count all the control points in the trimming curves of my trimmed surfaces

polysurface = rs.GetObject("Select polysurface",filter = 16, preselect = False, select = False)

intNbCurveCtrlPts = 0

brep = rs.coercebrep(polysurface)

for trim in brep.Trims:
    intNbCurveCtrlPts+=trim.ControlPolygon().Count

print(intNbCurveCtrlPts)