This works from a C#, RhinoCommon plug-in:
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
var on_mesh = new RMA.OpenNURBS.OnMesh(6, 8, false, false);
on_mesh.SetVertex(0, 0.5, 0.5, 0.5);
on_mesh.SetVertex(1, 0.5, 0.5, -0.5);
on_mesh.SetVertex(2, 0.5, -0.5, 0.5);
on_mesh.SetVertex(3, 0.5, -0.5, -0.5);
on_mesh.SetVertex(4, -0.5, 0.5, 0.5);
on_mesh.SetVertex(5, -0.5, 0.5, -0.5);
on_mesh.SetVertex(6, -0.5, -0.5, 0.5);
on_mesh.SetVertex(7, -0.5, -0.5, -0.5);
on_mesh.SetQuad(0, 0, 1, 5, 4);
on_mesh.SetQuad(1, 0, 4, 6, 2);
on_mesh.SetQuad(2, 0, 2, 3, 1);
on_mesh.SetQuad(3, 7, 3, 2, 6);
on_mesh.SetQuad(4, 7, 6, 4, 5);
on_mesh.SetQuad(5, 7, 5, 1, 3);
on_mesh.ComputeVertexNormals();
on_mesh.Compact();
if (on_mesh.IsValid())
{
var rh_mesh = Rhino.Runtime.Interop.FromOnMesh(on_mesh);
if (null != rh_mesh && rh_mesh.IsValid)
{
doc.Objects.AddMesh(rh_mesh);
doc.Views.Redraw();
}
}
return Result.Success;
}
Perhaps your function should validate the mesh parameter before trying to convert?
– Dale