Hi Ed,
I am using code you suggested and works fine as part of loop i am using to add points
below partial code
the problem i am facing is that when i am multiply Length 1 * L2 to get area, and if for some reason i draw extra segment on straight line the total area will be less than actual area see screen shot attached (test)
in attached example area will be Length 1*L2 = 1.89*0.78 result will be less than actual area (1.89*(0.78+1.34))
is there a way to add up lengths if they are on same direction such as adding L2+L3 to become 0.78+1.34
this way i can avoid mistakes in calculation
should i run test for example maybe if
dblXSl (i2) = dblXSl (i3) or
dblYSl (i2) =dblYSl (i3)
this means they are on same angle (direction)
n = 0
On Error Resume Next
For i = 0 To 2000 Step 3
Label1:
' first point use actual postion for exact location
AktPt = MyDWG.Utility.GetPoint
ReDim Preserve points(i + 5) As Double
plineObj.Delete
' first point
' x vertix
points(i) = AktPt(0)
' y vertix
points(i + 1) = AktPt(1)
' z vertix
points(i + 2) = AktPt(2)
points(i + 3) = points(0)
points(i + 4) = points(1)
points(i + 5) = points(2)
' jalal add length 2023
'Calc distance
If i = 0 Then GoTo labelnextpoint
dblXSl = (points(i) - points(i - 3)) ^ 2
dblYSl = (points(i + 1) - points(i - 2)) ^ 2
dblZSl = (points(i + 2) - points(i - 1)) ^ 2
'Return Distance
ReDim XYZDistance(n)
dblDist = Sqr(dblXSl + dblYSl + dblZSl)
XYZDistance(n) = dblDist
If n = 1 Then
UserForm_DrawToCalc.TextBoxshapeLength1 = Format(XYZDistance(n), "##,##0.00")
End If
If n = 2 Then
UserForm_DrawToCalc.TextBoxshapeLength2 = Format(XYZDistance(n), "##,##0.00")
End If
If n = 3 Then
UserForm_DrawToCalc.TextBoxshapeLength3 = Format(XYZDistance(n), "##,##0.00")
End If
If n = 4 Then
UserForm_DrawToCalc.TextBoxshapeLength4 = Format(XYZDistance(n), "##,##0.00")
End If
If n = 5 Then
UserForm_DrawToCalc.TextBoxshapeLength5 = Format(XYZDistance(n), "##,##0.00")
End If
If n = 6 Then
UserForm_DrawToCalc.TextBoxshapeLength6 = Format(XYZDistance(n), "##,##0.00")
End If
'TextBoxshapeLength = "TextBoxshapeLength" & n
' TextBoxshapeLength(n) = Format(XYZDistance(n), "##,##0.00")
'UserForm_DrawToCalc.
'UserForm_DrawToCalc.TextBoxshapeLength5 = Format(XYZDistance(5), "##,##0.00")
labelnextpoint:
Set plineObj = MyDWG.ModelSpace.AddPolyline(points)
'
'Return Distance
'LastplineObj = MyDWG.ModelSpace.AddPolyline(points)
If Err Then
Err.Clear