Site Tools


Create Surfaces from Corner Points

Developer: .NET
Summary: Demonstrates how to create a surface from specified corner points.
Notice: The Rhino.NET SDK is deprecated in Rhino 5. The example adapted for the new RhinoCommon SDK is here.

Question

Can anyone tell me how to run the SrfPt command from a C# plug-in? Specifically, I need to know the format for the string 'pt_surf' in this call:

RhUtil.RhinoApp().RunScript(pt_surf);

Answer

Instead of scripting the SrfPt command, why not just use the RhinoCreate1FaceBrepFromPoints function, which creates a surface from corner points? Here is an example of its use.

C#

public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
{
  IRhinoCommand.result rc = IRhinoCommand.result.failure;
 
  On3dPoint[] corners = new On3dPoint[4];
  corners[0] = new On3dPoint( 0.0,  0.0, 0.0);
  corners[1] = new On3dPoint(10.0,  0.0, 0.0);
  corners[2] = new On3dPoint(10.0, 10.0, 0.0);
  corners[3] = new On3dPoint( 0.0, 10.0, 0.0);
 
  OnBrep brep = RhUtil.RhinoCreate1FaceBrepFromPoints(corners);
  if (brep != null)
  {
    if (context.m_doc.AddBrepObject(brep) != null)
    {
      context.m_doc.Redraw();
      rc = IRhinoCommand.result.success;
    }
  }
 
  return rc;
}
developer/sdksamples/srfpt.txt ยท Last modified: 2016/01/05 by sandy