Python divide brep surfaces to get points

I am trying to get the grasshopper thing, but then in python.

I cannot find the rhinocommon code to divide a surface and get the points from there.
Do you might know the rhinocommon code for that?

Thank you for your response. :smiley:

problem divide brep surfaces to points (12.9 KB)

P and C# are light years apart … but you can the gist of the thing (I hope):

PS: What means Brep Surface? You tell me. Or maybe you mean that you want to respect inner/outer Loops for a given BrepFace ? (if so you should use a PointFaceRelation filtering schema [var pfr = face.IsPointOnFace(pt))

I want to divide the brepfaces like with the components to get points.
So, getting the brepfaces, I think I know, but getting the points, I think I do not know.

Is there a rhinocommon code to divide the surface like with the components and get the points.

What does j++ mean?

The syntax for the BrepFaces (a Surface WITH trim info) has as follows. Sure it’s C# … but the RhinoCommon Methods are the same anyway (i++ means increment by 1).

As far as I know, there isn’t any method with this functionality, but as @PeterFotiadis explaind we could achieve this by nested loops:

import Rhino.Geometry as rg
for face in brep.Faces:
    uSize, vSize = face.GetSurfaceSize()[1:]
    uDom = face.Domain(0)
    vDom = face.Domain(1)
    uNumberOfSegments = int(uSize/n)
    vNumberOfSegments = int(vSize/n)
    for i in range(uNumberOfSegments+1):
        for j in range(vNumberOfSegments+1):
            uParam = uDom.ParameterAt(i/uNumberOfSegments)
            vParam = vDom.ParameterAt(j/vNumberOfSegments)
            p.append(face.PointAt(uParam, vParam)) (13.9 KB)


thank you :smiley:

You could extend that approach to create panels, and also organize your lists as rows/columns using the tree helper functions. (If you are using Rhino 6). This example uses a dictionary to hold the point location, using row and column(i and j) location. Very similar to how paneling tools indexes point grids.

import Rhino
import ghpythonlib.treehelpers as th

pts = {}
srfs = []
grid = []

nrows = U
ncolumns = V

UDomain = Rhino.Geometry.Interval(0,U)
VDomain = Rhino.Geometry.Interval(0,V)
srf.SetDomain(0, UDomain)
srf.SetDomain(1, VDomain)

for i in range(0,nrows+1):
    gcolumn = []
    for j in range(0,ncolumns+1):
        pts[(i,j)] = Rhino.Geometry.Surface.PointAt(srf,i,j)
for i in range(0, nrows):
    pcolumn = []
    for j in range(0, ncolumns):
        panel = Rhino.Geometry.NurbsSurface.CreateFromCorners(pts[i,j],pts[i+1,j],pts[i+1,j+1],pts[i,j+1])

srfs = th.list_to_tree(srfs)
grid = th.list_to_tree(grid)

srf : type hint Surface, Item Acces
U: type hint Integer, Item Access
V: type hint Integer, Item Access

Or, if you were using native components, you could just use the Mesh Surface Component, Explode the mesh, get the vertices of the faces, then make surface panels from the 4 points, (assuming a quad mesh to start with).


Hello everyone,

Thanks for all the previous solutions and helps for this issue, but I am facing a weird mathematical problem. I don’t know why it is reversing the problem.

Would be thankful to have your helps.

**I will share a screenshot of it + the .gh file.

DivSrf (8.4 KB)