Hi, I am giving PolylineCurve List as input. That means I have 100 closed planer Polyline Curve and I want a single mesh with ngons .
With single Ngon I could work out how it works.
–Can I take multiple NGons as input and get a single mesh ?
–Does NGon supported in grasshopper Rhino 6?
I tried to draw Ngon mesh, but it is giving only the Ngon for the last Polyline curve in the list.
Just one Ngon.
I never used Ngon before, so please let me know what I did wrong below:
It can be a silly mistake but I am not able to find it ;
public static Mesh MeshFromPolyline(List<PolylineCurve> plineR)
{
Mesh mesh = null;
int countd = 0;
int countf = 0;
for (int i = 0; i < plineR.Count; i++)
{
if (null != plineR[i] &&
plineR[i].IsClosed &&
plineR[i].IsPlanar() &&
plineR[i].PointCount >= 4
)
{
mesh = Mesh.CreateFromClosedPolyline(plineR[i].ToPolyline());
if (null != mesh)
{
var vertices_ind_list = new List<int>(mesh.Vertices.Count);
for (var vi = 0; vi < mesh.Vertices.Count; vi++)
{
vertices_ind_list.Add(countd + vi);
}
countd = countd + mesh.Vertices.Count;
var faces_ind_list = new List<int>(mesh.Faces.Count);
for (var fi = 0; fi < mesh.Faces.Count; fi++)
{
faces_ind_list.Add(countf + fi);
}
countf = countf + mesh.Faces.Count;
var ngon = MeshNgon.Create(vertices_ind_list.ToArray(),
faces_ind_list.ToArray());
if (null != ngon)
mesh.Ngons.AddNgon(ngon);
}
}
}
if (null != mesh)
{
mesh.FaceNormals.ComputeFaceNormals();
mesh.Normals.ComputeNormals();
mesh.Compact();
if (!mesh.IsValid)
mesh = null;
}
return mesh;
}