View Full Version : Looping Vertices
03-14-2007, 05:48 PM
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.:(
03-15-2007, 05:11 PM
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;
03-15-2007, 06:01 PM
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;
int numEntries = (int)thisType.InvokeMember("Length", BindingFlags.GetProperty, null, obj, null);
if (numEntries > 0)
for (int j = 0; j < numEntries; j++)
args = j;
objLoc[j] = (MapPoint.Location)thisType.InvokeMember("GetValue", BindingFlags.InvokeMethod, null, obj, args);
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.
Search Engine Friendly URLs by vBSEO