@lukert.david wrote:
Hey there,
I’m trying to create a C# component, where you input two curves and divide them x times.
The Points on the curves should be the vertices for a quadrangular mesh.
Although the preview doesn’t look that bad i get an invalid mesh as output.The exact statement is:
Mesh: ON_Mesh.m_F [4] .vi[ ] has invalid vertex indices.Thanks for your help!
Lukertplugintest4.gh (5.6 KB)
The Code:
private void RunScript(Curve iCurve1, Curve iCurve2, int iSegments, ref object Mesh, ref object Vertices, ref object Validity)
{List<Point3d> ptsCurve1 = new List<Point3d>(); List<Point3d> ptsCurve2 = new List<Point3d>(); Point3d ptCurve1 = new Point3d(); Point3d ptCurve2 = new Point3d(); double spacing = 1.0 / iSegments; double t; // divide curves for (int i = 0; i < iSegments; i++) { t = i * spacing; ptCurve1 = iCurve1.PointAtNormalizedLength(t); ptsCurve1.Add(ptCurve1); ptCurve2 = iCurve2.PointAtNormalizedLength(t); ptsCurve2.Add(ptCurve2); } // reverse list if indices are on the wrong side if (ptsCurve1[0].DistanceTo(ptsCurve2[0]) > ptsCurve1[0].DistanceTo(ptsCurve2[iSegments - 1])) { ptsCurve2.Reverse(); } Mesh mesh = new Mesh(); for (int i = 0; i < iSegments; i++) { mesh.Vertices.Add(ptsCurve1[i]); mesh.Vertices.Add(ptsCurve2[i]); } for (int i = 0; i < mesh.Vertices.Count; i += 2) { mesh.Faces.AddFace(i, i + 1, i + 3, i + 2); } Mesh = mesh; Vertices = mesh.Vertices; Validity = GH_Format.FormatMeshValidity(mesh);
}
Posts: 4
Participants: 3