> ficus
Для ознакомления, возможно извлечешь отсюда
все что тебе нужно
Option Explicit
Sub GetBulgeRadiuses()
Dim oent As AcadEntity
Dim varpt
Dim opoly As AcadLWPolyline
Dim rad As Double, ang As Double, b As Double, d As Double
Dim c As Double, i As Long, j As Long, bulge As Double, pi As Double
Dim coors As Variant, p1 As Variant, p2 As Variant, cpt(2) As Double
Dim pt1(2) As Double, pt2(2) As Double, s As String
pi = 3.14159265358979: s = ""
ThisDrawing.Utility.GetEntity oent, varpt, "select"
Set opoly = oent
coors = opoly.Coordinates
j = 0
For i = 0 To (UBound(coors) / 2 - 1) - 1
bulge = opoly.GetBulge(j)
If bulge <> 0 Then
p1 = opoly.Coordinate(i)
p2 = opoly.Coordinate(i + 1)
pt1(0) = p1(0): pt1(1) = p1(1): pt1(2) = opoly.Elevation
pt2(0) = p2(0): pt2(1) = p2(1): pt2(2) = opoly.Elevation
ang = ThisDrawing.Utility.AngleFromXAxis(pt1, pt2)
b = Atn(bulge) * 2
d = Get_Distance(p1, p2) / 2
If bulge > 0 Then
c = ang + pi / 2 - b
Else
c = ang - pi / 2 - b
End If
rad = Abs(d / Sin(b))
cpt(0) = p1(0) + Cos(c) * rad
cpt(1) = p1(1) + Sin(c) * rad
cpt(2) = 0
MsgBox "Bulge: " & bulge
s = s & CStr(rad) & vbCrLf
MsgBox "Center: " & vbNewLine & cpt(0) & "," & cpt(1) & "," & cpt(2)
ThisDrawing.ModelSpace.AddCircle cpt, rad
End If
j = j + 1
Next
MsgBox "All radiuses: " & s
End Sub
Public Function Get_Distance(fPoint As Variant, sPoint As Variant) As Double
Dim x1 As Double, x2 As Double
Dim y1 As Double, y2 As Double
Dim z1 As Double, z2 As Double
Dim cDist As Double
x1 = fPoint(0): y1 = fPoint(1)
If UBound(fPoint) = 2 Then z1 = fPoint(2) Else z1 = 0#
x2 = sPoint(0): y2 = sPoint(1)
If UBound(sPoint) = 2 Then z2 = sPoint(2) Else z2 = 0#
cDist = Sqr(((x2 - x1) ^ 2) + ((y2 - y1) ^ 2) + ((z2 - z1) ^ 2))
Get_Distance = cDist
End Function
Function Arcos(v) As Double
If v >= -1 And v <= 1 Then
Arcos = Atn(Sqr(1 - v ^ 2))
Else
Arcos = v
End If
End Function
Function AngleThreePts(cpt As Variant, p1 As Variant, p2 As Variant) As Double
Dim ang As Double, d1 As Double, d2 As Double, d3 As Double
d1 = Get_Distance(cpt, p1)
d2 = Get_Distance(cpt, p2)
d3 = Get_Distance(p1, p2)
If d1 <> 0 Or d1 <> 0 Or d3 <> 0 Then
ang = Arcos((d1 ^ 2 + d2 ^ 2 - d3 ^ 2) / d1 * d2 * 2)
Else
ang = 0#
End If
AngleThreePts = ang
End Function
~'J'~