Any body has a sample C# code to loop through the vertices of freeform shape? I'm not C# guru and I tried many ways and I always failed.![]()
This is a discussion on Looping Vertices within the MapPoint Desktop Discussion forums, part of the Map Forums category; Any body has a sample C# code to loop through the vertices of freeform shape? I'm not C# guru and ...
Any body has a sample C# code to loop through the vertices of freeform shape? I'm not C# guru and I tried many ways and I always failed.![]()
I'd recommend Chandu Thota's "Programming MapPoint in .NET". I haven't tried it (yet), but pg.108 has the following code:
object[] vertices = shape.Vertices as object[];
foreach(object vertex in vertices)
{
MapPoint.Location loc = vertex as MapPoint.Location;
}
Richard
Winwaed Software Technology LLC
http://www.winwaed.com
See http://www.mapping-tools.com for MapPoint Tools
Thanks, Richard. I test it and your sample code works fine.
I fingured out the shape vertices is actual a COM object, I used following way to solve the problem. Silly but works.![]()
Object obj = shape.Vertices;
Type thisType = obj.GetType();
object[] args = new object[1];
int numEntries = (int)thisType.InvokeMember("Length", BindingFlags.GetProperty, null, obj, null);
if (numEntries > 0)
{
for (int j = 0; j < numEntries; j++)
{
args[0] = j;
objLoc[j] = (MapPoint.Location)thisType.InvokeMember("GetValue ", BindingFlags.InvokeMethod, null, obj, args);
}
}
There are currently 1 users browsing this thread. (0 members and 1 guests)