PDA

View Full Version : Line lengths


YosSa
02-09-2004, 09:19 AM
Hi Guys ..
I made a VBA routine to get lengths of lines out of a drawing.
Now how can i make it work for PLINES ??

Dont have more time to figure it out. Only had 1 hour to make this

TCARPENTER
02-09-2004, 07:07 PM
YosSa,

I took a brief look at your code, I haven't really had a chance to dig into it but if it helps, you'll need to extract the coordinates from the selected polyline, and then calculate the distance between each point - I'm not a heavy math guru, but you'll probably need to think along the lines of the Pythagorean theorem. In short:

varArray = objPline.GetCoordinates

' Walk the varArray
'
For iCnt = LBound(varArray) to UBound(varArray) Step 2
X = varArray(iCnt)
Y = varArray(iCnt + 1)
Dist = Dist + Sqr((X*X) + (Y*Y))
Next iCnt

....


That's not all you'll need, (some polylines return X, Y, Z), but at least (I hope) it'll get you going.

HTH
Todd