Hi everyone,
I am trying to create a surface from a polyline in c# but I am stuck…
This is the code I have:
using System;
using System.Collections.Generic;
using System.Linq;
using Rhino;
using Rhino.Geometry;
using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;
public class Script_Instance : GH_ScriptInstance
{
private void RunScript(Polyline P, ref object S)
{
if (!P.IsClosed) return;
Curve c = P.ToNurbsCurve();
double tol = Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance;
Brep[] breps = Brep.CreatePlanarBreps(c, tol);
if (breps != null && breps.Length > 0)
{
S = breps[0].Faces[0].DuplicateSurface();
}
}
}
In this image you can see the polyline and the result… It seems I am always creating a 4 corner surface but I do not know what is wrong…
Can someone take a look?
Thanks a lot!
