View Single Post

  #2 (permalink)  
Old 03-28-2008
DRZ400 DRZ400 is offline
Junior Member
White Belt
 
Join Date: Mar 2008
Posts: 2
Re: Circumference of a geoFreeform or Polygon

Hi all,

I've figured it out with the help of all the info on this forum. Here's my vb6 code, I hope it saves someone else of 2 days of hell!!

Here's the bit that calculates distance between all the vertices for the selected freeform shape.

Code:
Dim curshape As Integer
Dim objLoc1 As MapPointCtl.Location
Dim objLoc2 As MapPointCtl.Location
Set obj1 = objMap.Selection
'curshape = obj1.Name
n = UBound(obj1.Vertices)
dist = 0
i = 0
Text6.Text = 0
For i = 0 To (n - 1) ' loop through all the points
    Set objLoc1 = obj1.Vertices(i)
    Set objLoc2 = obj1.Vertices(i + 1)
    dist = dist + objMap.Distance(objLoc1, objLoc2)
 
Next i
 ' calculate the distance from the end point back to the start point
    Set objLoc1 = obj1.Vertices(0)
    Set objLoc2 = obj1.Vertices(i)
    dist = dist + objMap.Distance(objLoc1, objLoc2)
Text6.Text = Int(dist)
obj1.SizeVisible = True
It's not the best code as I'm not that good but it works and I'm chuffed!!!

Time for a beer!

Cheers
Phil

Last edited by DRZ400; 03-29-2008 at 03:37 PM. Reason: replaced "objMap.Shapes.Item(curshape)." with "obj1"
Reply With Quote