algorithmic modeling for Rhino
I want to program using GhPython to get the following information for each of the surfaces within a geometry (brep or polygon or mesh geometry):
- surface centroid coordinate and vector of the surface normal
- coordinators of the corners of a surface
However, it seems I could not get the individual surface objects within a geometry in the first place:
Can anybody advise on a general workflow in this regard?
Thank you!
Tags:
Hi Grasshoppe
surfaces are untrimmed NURBS surfaces. When a surface is trimmed, Rhino regards is as a Brep. One single Brep, though, can contain more than one trimmed parts. Therefore, you will have to explode a brep in order to get to its constituent (brep) parts.
Attached is a script that shows how to do that (using rhinoscriptsyntax).
In the future please post the file you are working on. I hope this helps,
Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com
Thank you, Giulio!
I have two new problems in:
1. adding text besides a point (line 16 of the code) doesn't work
2. find corners of a concave surface (line 27&28) (I'm expecting to get the 6 corners of the last surface in the Brep, however, only the corners of the bounding box of the surface are generated)
It seems the rs.SurfacePoints only returens the control points of a surface rather than the actual corners of the surface. Can you advise if there's a way to do it?
Thank you!
Code:
import rhinoscriptsyntax as rs
all_parts = rs.ExplodePolysurfaces(brep)
centers = []
vectors = []
lines = []
vertices = []
cnt = 0
for part in all_parts:
center, err = rs.SurfaceAreaCentroid(part)
centers.append(center)
#rs.AddText(str(cnt), center)
uv = rs.SurfaceClosestPoint(part, center)
vector = rs.SurfaceNormal(part, uv)
vectors.append(vector)
N_start = center
N_end = rs.VectorAdd(center, vector)
line = rs.AddLine(N_start, N_end)
lines.append(line)
#vertices = rs.SurfacePoints(part)
vertices = rs.SurfaceEditPoints(part)
cnt +=1
#C = centers
#N = vectors
#L = lines
V = vertices
#todo:
#explore the surface methods in rhinoscript.surface...
#import rhinoscript.surface.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by