Skip to content

Instantly share code, notes, and snippets.

@sbaer
Created April 30, 2012 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbaer/2559479 to your computer and use it in GitHub Desktop.
Save sbaer/2559479 to your computer and use it in GitHub Desktop.
Brep.CreateFromSweep Sample
Protected Overrides Function RunCommand(ByVal doc As RhinoDoc, ByVal mode As Rhino.Commands.RunMode) As Rhino.Commands.Result
Dim command_rc As Rhino.Commands.Result
' Sweep the cross section
Dim rhobj As Rhino.DocObjects.ObjRef = Nothing
command_rc = Rhino.Input.RhinoGet.GetOneObject("Profile shape", False, DocObjects.ObjectType.Curve, rhobj)
If command_rc <> Commands.Result.Success Then Return command_rc
Dim shape As Rhino.Geometry.Curve = rhobj.Curve()
If shape Is Nothing Then Return Commands.Result.Failure
doc.Objects.UnselectAll()
command_rc = Rhino.Input.RhinoGet.GetOneObject("Sweep curve", False, DocObjects.ObjectType.Curve, rhobj)
If command_rc <> Commands.Result.Success Then Return command_rc
Dim rail As Rhino.Geometry.Curve = rhobj.Curve()
If rail Is Nothing Then Return Commands.Result.Failure
Dim breps() As Rhino.Geometry.Brep = Rhino.Geometry.Brep.CreateFromSweep(rail, shape, rail.IsClosed, doc.ModelAbsoluteTolerance)
For Each brep As Rhino.Geometry.Brep In breps
doc.Objects.AddBrep(brep)
Next
doc.Views.Redraw()
Return Rhino.Commands.Result.Success
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment