Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

developer:rhinocommonsamples:loft [2015/09/14] (current)
Line 1: Line 1:
 +===== Sample: Loft Surfaces =====
 +
 +===== C# =====
 +<code c#>
 +[System.Runtime.InteropServices.Guid("​5D48CD31-B300-42B4-98F0-A7A4004B5227"​)]
 +public class LoftCommand : Command
 +{
 +  public override string EnglishName { get { return "​csLoft";​ } }
 +
 +  protected override Result RunCommand(RhinoDoc doc, Rhino.Commands.RunMode mode)
 +  {
 +    // select curves to loft
 +    var gs = new GetObject();​
 +    gs.SetCommandPrompt("​select curves to loft"​);​
 +    gs.GeometryFilter = ObjectType.Curve;​
 +    gs.DisablePreSelect();​
 +    gs.SubObjectSelect = false;
 +    gs.GetMultiple(2,​ 0);
 +    if (gs.CommandResult() != Result.Success)
 +      return gs.CommandResult();​
 +
 +    var curves = new List<​Curve>​();​
 +    foreach (var obj in gs.Objects())
 +      curves.Add(obj.Curve());​
 +
 +    var breps = Rhino.Geometry.Brep.CreateFromLoft(curves,​ Point3d.Unset,​ Point3d.Unset,​ LoftType.Tight,​ false);
 +    foreach (var brep in breps)
 +      doc.Objects.AddBrep(brep);​
 +
 +    doc.Views.Redraw();​
 +    return Result.Success;​
 +  }
 +}
 +</​code>​
 +===== VB.NET =====
 +<code vb>
 +<​System.Runtime.InteropServices.Guid("​DB81E4AA-9CD2-4556-AF31-614C739048B9"​)>​ _
 +Public Class LoftCommand
 +  Inherits Command
 +  Public Overrides ReadOnly Property EnglishName() As String
 +    Get
 +      Return "​vbLoft"​
 +    End Get
 +  End Property
 +
 +  Protected Overrides Function RunCommand(doc As RhinoDoc, mode As Rhino.Commands.RunMode) As Result
 +    ' select curves to loft
 +    Dim gs = New GetObject()
 +    gs.SetCommandPrompt("​select curves to loft")
 +    gs.GeometryFilter = ObjectType.Curve
 +    gs.DisablePreSelect()
 +    gs.SubObjectSelect = False
 +    gs.GetMultiple(2,​ 0)
 +    If gs.CommandResult() <> Result.Success Then
 +      Return gs.CommandResult()
 +    End If
 +
 +    Dim curves = New List(Of Curve)()
 +    For Each obj As ObjRef In gs.Objects()
 +      curves.Add(obj.Curve())
 +    Next
 +
 +    Dim breps = Rhino.Geometry.Brep.CreateFromLoft(curves,​ Point3d.Unset,​ Point3d.Unset,​ LoftType.Tight,​ False)
 +    For Each brep As Brep In breps
 +      doc.Objects.AddBrep(brep)
 +    Next
 +
 +    doc.Views.Redraw()
 +    Return Result.Success
 +  End Function
 +End Class
 +d Namespace
 +</​code>​
 +===== Python =====
 +<code python>
 +import rhinoscriptsyntax as rs
 +
 +def RunCommand():​
 +  crvids = rs.GetObjects(message="​select curves to loft", filter=rs.filter.curve,​ minimum_count=2)
 +  if not crvids: return
 +
 +  rs.AddLoftSrf(object_ids=crvids,​ loft_type = 3) #3 = tight
 +
 +if __name__ == "​__main__":​
 +  RunCommand()
 +</​code>​
 +
 +{{tag>​Developer rhinocommon}}
  
developer/rhinocommonsamples/loft.txt ยท Last modified: 2015/09/14 (external edit)