Sweep Surfaces with Sweep1

Demonstrates how to sweep along a single rail curve.

partial class Examples
  public static Rhino.Commands.Result Sweep1(Rhino.RhinoDoc doc)
    Rhino.DocObjects.ObjRef rail_ref;
    var rc = RhinoGet.GetOneObject("Select rail curve", false, Rhino.DocObjects.ObjectType.Curve, out rail_ref);
      return rc;

    var rail_crv = rail_ref.Curve();
    if( rail_crv==null )
      return Rhino.Commands.Result.Failure;

    var gx = new Rhino.Input.Custom.GetObject();
    gx.SetCommandPrompt("Select cross section curves");
    gx.GeometryFilter = Rhino.DocObjects.ObjectType.Curve;
    gx.EnablePreSelect(false, true);
    if( gx.CommandResult() != Rhino.Commands.Result.Success )
      return gx.CommandResult();

    var cross_sections = new List<Rhino.Geometry.Curve>();
    for( int i=0; i<gx.ObjectCount; i++ )
      var crv = gx.Object(i).Curve();
      if( crv!= null)
    if( cross_sections.Count<1 )
      return Rhino.Commands.Result.Failure;

    var sweep = new Rhino.Geometry.SweepOneRail();
    sweep.AngleToleranceRadians = doc.ModelAngleToleranceRadians;
    sweep.ClosedSweep = false;
    sweep.SweepTolerance = doc.ModelAbsoluteTolerance;
    var breps = sweep.PerformSweep(rail_crv, cross_sections);
    for( int i=0; i<breps.Length; i++ )
    return Rhino.Commands.Result.Success;
Partial Friend Class Examples
  Public Shared Function Sweep1(ByVal doc As Rhino.RhinoDoc) As Rhino.Commands.Result
	Dim rail_ref As Rhino.DocObjects.ObjRef = Nothing
	Dim rc = RhinoGet.GetOneObject("Select rail curve", False, Rhino.DocObjects.ObjectType.Curve, rail_ref)
	If rc IsNot Rhino.Commands.Result.Success Then
	  Return rc
	End If

	Dim rail_crv = rail_ref.Curve()
	If rail_crv Is Nothing Then
	  Return Rhino.Commands.Result.Failure
	End If

	Dim gx = New Rhino.Input.Custom.GetObject()
	gx.SetCommandPrompt("Select cross section curves")
	gx.GeometryFilter = Rhino.DocObjects.ObjectType.Curve
	gx.EnablePreSelect(False, True)
	If gx.CommandResult() <> Rhino.Commands.Result.Success Then
	  Return gx.CommandResult()
	End If

	Dim cross_sections = New List(Of Rhino.Geometry.Curve)()
	For i As Integer = 0 To gx.ObjectCount - 1
	  Dim crv = gx.Object(i).Curve()
	  If crv IsNot Nothing Then
	  End If
	Next i
	If cross_sections.Count<1 Then
	  Return Rhino.Commands.Result.Failure
	End If

	Dim sweep = New Rhino.Geometry.SweepOneRail()
	sweep.AngleToleranceRadians = doc.ModelAngleToleranceRadians
	sweep.ClosedSweep = False
	sweep.SweepTolerance = doc.ModelAbsoluteTolerance
	Dim breps = sweep.PerformSweep(rail_crv, cross_sections)
	For i As Integer = 0 To breps.Length - 1
	Next i
	Return Rhino.Commands.Result.Success
  End Function
End Class
import rhinoscriptsyntax as rs
import Rhino
import scriptcontext

def Sweep1():
    rail = rs.GetObject("Select rail curve", rs.filter.curve)
    rail_crv = rs.coercecurve(rail)
    if not rail_crv: return

    cross_sections = rs.GetObjects("Select cross section curves", rs.filter.curve)
    if not cross_sections: return
    cross_sections = [rs.coercecurve(crv) for crv in cross_sections]

    sweep = Rhino.Geometry.SweepOneRail()
    sweep.AngleToleranceRadians = scriptcontext.doc.ModelAngleToleranceRadians
    sweep.ClosedSweep = False
    sweep.SweepTolerance = scriptcontext.doc.ModelAbsoluteTolerance
    breps = sweep.PerformSweep(rail_crv, cross_sections)
    for brep in breps: scriptcontext.doc.Objects.AddBrep(brep)

if __name__ == "__main__":