# Creating BREP or Surface (or NURBS Surface) from a set of coordinates

I am attempting to create a BREP/Surface/Mesh using a set of point coordinates inside a list (which I can turn into Rhino.Geometry.Point3d objects and also to Curve objects), that describe irregular polygons (sometimes with holes or ‘Inner Loops’, according to BREP terminology). A sample shape (EDIT: a planar surface with six inner loops and one outer loop) is attached as .3dm here:
sample.3dm (54.4 KB)

and it looks like this:

Previously, I was using CreateFromCornerPoints (which I understand creates one BREP face) to make quadrilaterals.

However, based on what I’ve seen in the Developer methods and also on the forum, creating a BREP from scratch using scripting appears to be very difficult. How then do I best go about creating BREP/Surface from scratch using a set of Point3d/Curve objects in Python and Rhinocommon? Are there workarounds to direct BREP construction? If you could provide me with links to similar discussions (which I may have missed) or with a simple example for an irregular polygon with one inner loop as Rhino Geometry (so that they can first be previewed using Grasshopper, and are not added to the Rhino document right away), then I can take it from there.

The output would need to be a Surface (trimmed in this case), and it would need to be able to handle any number of sides and Inner Loops. I understand that after the main BREP face is made, then one ‘trims’ it with the BREP faces that serve as ‘holes’.

TLDR; I want to recreate a shape like the one above as a BREP/Surface, but the only data I have about that shape are its coordinates (Point3d objects), normal, u and v vectors. How do I do it in Python with the output being Rhino.Geometry (not GUIDs) in the least painful way?

Actually that’s a planar surface with 7 trim loops, 6 inner and one outer.

Dunno, seems that you are making it pretty complicated… Can you not use Rhino.Geometry.Brep.CreatePlanarBreps(IEnumerable) with your curve collection? Or do I not understand what you want?

If all you have is a set of points, that’s completely arbitrary, any number of surfaces could be made from the same set of points without additional rules… I think you might need to figure out how to “connect the dots” in this case. If you can create a set of closed coplanar curves from your points, CreatePlanarBreps() will be your best bet.

–Mitch

Hi @Helvetosaur, I am able to create a Curve collection using the points, since I know what their order would be. So if I understand correctly, you suggest the following:

Point 3d -> Curve Collection -> Rhino.Geometry.Brep.CreatePlanarBreps(‘Curve Collection Variable’)

Is this correct?

Update: So I’m able to create the outer loop with no problem, but BrepObject.Trim() doesn’t seem to be returning a Trimmed Surface, so any suggestions on how to put in inner loops?

You don’t need to trim anything, just pass your entire list of curves - outer and inner loops - to Brep.CreatePlanarBreps([curvelist]) and watch the magic…

You can try the attached file of curves with the script snippet below…

PlanarCrvs.3dm (226.8 KB)

``````import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

crvIDs=rs.GetObjects("Select curves",4,preselect=True)
if crvIDs:
crvs=[rs.coercecurve(crvID) for crvID in crvIDs]
breps=Rhino.Geometry.Brep.CreatePlanarBreps(crvs)
if breps: