我开始一个例行程序,添加尺寸的折线。。。
问题是,它是在直线上创建的,我想将其与直线分开创建,如果有人能帮助我,这将是非常棒的。。。
谢谢
- Sub add_dim_polyline()
- 'to add Panel Dimensions
- Dim ThePolyline As AcadLWPolyline
- Dim polyCoords As Variant
- Dim getPoint As Variant
- Dim a As Integer
- Dim polyCoordBound As Integer
- Dim stPoint(2) As Double
- Dim ePoint(2) As Double
- Dim sectionAngle As Double
- Dim textCoords As Variant
- Dim polyDist As Double
- Dim x1, x2, y1, y2 As Double
- Dim objDimAligned As AcadDimAligned
- ThisDrawing.Utility.GetEntity ThePolyline, getPoint, "Select an object"
- polyCoords = ThePolyline.Coordinates
- polyCoordBound = UBound(polyCoords)
- For a = 0 To polyCoordBound - 1 Step 2
- If a = polyCoordBound - 1 Then
- stPoint(0) = polyCoords(a)
- stPoint(1) = polyCoords(a + 1)
- stPoint(2) = 0
- ePoint(0) = polyCoords(0)
- ePoint(1) = polyCoords(1)
- ePoint(2) = 0
- Else
- stPoint(0) = polyCoords(a)
- stPoint(1) = polyCoords(a + 1)
- stPoint(2) = 0
- ePoint(0) = polyCoords(a + 2)
- ePoint(1) = polyCoords(a + 3)
- ePoint(2) = 0
- End If
- x1 = stPoint(0): x2 = ePoint(0)
- y1 = stPoint(1): y2 = ePoint(1)
- polyDist = Sqr(((x1 - x2) ^ 2) + ((y1 - y2) ^ 2))
- sectionAngle = ThisDrawing.Utility.AngleFromXAxis(stPoint, ePoint)
- textCoords = ThisDrawing.Utility.PolarPoint(stPoint, sectionAngle, polyDist / 2)
- Set objDimAligned = ThisDrawing.ModelSpace.AddDimAligned(stPoint, ePoint, textCoords)
- Next a
- End Sub
|