BREP
Methods
BREPs as all Rhino objects are equipped with properties and methods, which you can find here
Methods
To create BREP several methods can be used, among these methods we have:
Create BREP using Sweep
import Rhino
import scriptcontext
# Prompt the user to select the rail curve
rail_obj_ref = Rhino.Input.RhinoGet.GetOneObject("Select the rail curve", False, Rhino.DocObjects.ObjectType.Curve)
rail = rail_obj_ref[1].Curve()
# Prompt the user to select the section curves
section_obj_refs = Rhino.Input.RhinoGet.GetMultipleObjects("Select the section curves", False, Rhino.DocObjects.ObjectType.Curve)
sections = [obj_ref.Curve() for obj_ref in section_obj_refs[1]]
# Create the sweep
sweep = Rhino.Geometry.Brep.CreateFromSweep(rail, sections, True, 0.001)
# Add the sweep to the document
if sweep:
for brep in sweep:
scriptcontext.doc.Objects.AddBrep(brep)
Create BREP using Loft
import Rhino
import scriptcontext
import rhinoscriptsyntax as rs
# Promt for picking Curves
crvs = rs.GetObjects("Pick the objects", 4)
#Convert from GUIDS to Rhino Geometry Curves
crvs = [rs.coercecurve(crv) for crv in crvs]
# Create a loft
loft = Rhino.Geometry.Brep.CreateFromLoft(crvs, Rhino.Geometry.Point3d.Unset,
Rhino.Geometry.Point3d.Unset,
Rhino.Geometry.LoftType.Normal,False)
# If loft creation was successful, add it to the document
if loft:
for brep in loft:
scriptcontext.doc.Objects.AddBrep(brep)
scriptcontext.doc.Views.Redraw()
else:
print("Failed to create loft.")
Cap Planar Holes
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)
# Cap the planar holes
capped_brep = brep.CapPlanarHoles(scriptcontext.doc.ModelAbsoluteTolerance)
# Bake the capped brep to the document
if capped_brep:
scriptcontext.doc.Objects.AddBrep(capped_brep)
# Delete the input polysurface
scriptcontext.doc.Objects.Delete(brep_id, True)
🛠 Exercise
00: 🐍⬇️⬇️⬇️ Download the script here ⬇️⬇️⬇️🐍
Solution
00: 🐍⬇️⬇️⬇️ Download the script here ⬇️⬇️⬇️🐍