BREP Properties


Main methods and properties


BREPs as all Rhino objects are equipped with properties and methods, which you can find here

Properties


Among the main properties, we have:

BREP Edges

import Rhino
import scriptcontext
import rhinoscriptsyntax as rs

# Prompt to select a polysurface
brep_id = rs.GetObject("Select a polysurface", 16)

# Convert from GUID to Rhino Geometry BREP
brep = rs.coercebrep(brep_id)

# Extract edges
edges = [edge.ToNurbsCurve() for edge in brep.Edges]

# Bake the edges as lines to the document
for edge in edges:
   scriptcontext.doc.Objects.AddCurve(edge)

BREP Vertices

import Rhino
import scriptcontext
import rhinoscriptsyntax as rs


# Promt to select a polysurface
brep = rs.GetObject("select a polysurface" , 16)

#Convert from GUIDS to Rhino Geometry BREP
brep = rs.coercebrep(brep)

# Extract vertices
vertices = [v.Location for v in brep.Vertices]

# Print vertices
for vertex in vertices:
   print("Vertex at {0}, {1}, {2}".format(vertex.X, vertex.Y, vertex.Z))
   
# Bake the vertices as points to the document
for vertex in vertices:
   scriptcontext.doc.Objects.AddPoint(vertex)

BREP Faces

import Rhino
import scriptcontext
import rhinoscriptsyntax as rs

# Prompt to select a polysurface
brep_id = rs.GetObject("Select a polysurface", 16)

# Convert from GUID to Rhino Geometry BREP
brep = rs.coercebrep(brep_id)

# Extract faces
faces = [face.DuplicateFace(False) for face in brep.Faces]

# Bake the faces as surfaces to the document
for face in faces:
  scriptcontext.doc.Objects.AddBrep(face)

🛠 Exercise


00 : 🐍⬇️⬇️⬇️ Download the script here ⬇️⬇️⬇️🐍


01 : 🐍⬇️⬇️⬇️ Download the script here ⬇️⬇️⬇️🐍 01 :🦏⬇️⬇️⬇️ Download the 3dm here ⬇️⬇️⬇️🦏


🛠 Solution

00 :🐍⬇️⬇️⬇️ Download the script here ⬇️⬇️⬇️🐍 01 :🐍⬇️⬇️⬇️ Download the script here ⬇️⬇️⬇️🐍