When testing a command that relies on the mesh topology indices, I found that after a mesh is rotated that the topology indices are incorrect. Clicking on a mesh edge will in fact give access to a completely different mesh edge.
This is on Rhino 5SR4.
To reproduce this bug, use the command below:
- Create a mesh on any surface.
- run the command below and select a mesh edge. it will be “reproduced” as a red line in the document.
- now rotate the mesh by 90 degrees (the exact angle probably does not matter).
- run the command again and select the same mesh edge (which is now rotated). Another mesh edge will be “reproduced” as a red line.
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
GetObject go = new GetObject();
go.SetCommandPrompt("Select mesh edge");
go.AcceptNothing(true);
go.GeometryFilter = ObjectType.MeshEdge;
while (true)
{
doc.Objects.UnselectAll(true);
GetResult res = go.Get();
if (res == GetResult.Cancel)
return Result.Cancel;
if (res == GetResult.Object)
{
ObjRef aRef = go.Object(0);
if (null != aRef)
{
if (aRef.GeometryComponentIndex.ComponentIndexType == ComponentIndexType.MeshTopologyEdge)
{
RhinoObject meshObject = doc.Objects.Find(aRef.ObjectId);
Mesh mesh = meshObject.Geometry as Mesh;
if (null == mesh)
continue;
Line edge = mesh.TopologyEdges.EdgeLine(aRef.GeometryComponentIndex.Index);
doc.Objects.AddLine(edge,
new ObjectAttributes
{
ColorSource = ObjectColorSource.ColorFromObject,
ObjectColor = Color.Red
});
return Result.Success;
}
}
}
}
}