Mesh Report Debug V0.gh (1.1 MB)
Hi, I am trying to learn C# scripting, and I’ve created a simple script that generates a mesh report. However, I’m encountering an issue—it doesn’t work with meshes that have no naked edges. I’ve spent hours trying to debug it, but I haven’t had good results.
Could you please help me identify the problem?
Thank you!
The error message shows:
Object reference not set to an instance of an object. (line: 96)
GetNakedEdges() returns null (not an empty array) for meshes without naked edges. So to iterate over the array of polylines you need to first check if the returned value is null before proceeding with the iteration. Here’s how to do it:
int nNakedEdges = 0;
Polyline[] plines = M.GetNakedEdges();
if (plines != null)
{
for (int i = 0; i < plines.Length; i++)
nNakedEdges += plines[i].Count - 1;
}