AutoCAD VBA基本多段线操作,包括创建直线,圆,圆弧等,代码如下。
Public Function AddLWPline(ByRef pt() As Double, ByVal width As Double) As AcadLWPolyline
Dim objPline As AcadLWPolyline
If (UBound(pt) + 1) Mod 2 <> 0 Then
MsgBox "数组元素个数必须为偶数"
Exit Function
End If
Set objPline = ThisDrawing.ModelSpace.AddLightWeightPolyline(pt)
objPline.ConstantWidth = width
objPline.Update
Set AddLWPline = objPline
End Function
Public Function AddLWPlineSeg(ByVal ptSt As Variant, ByVal ptEn As Variant, ByVal width As Double) As AcadLWPolyline
Dim objPline As AcadLWPolyline
Dim ptArr(0 To 3) As Double
ptArr(0) = ptSt(0)
ptArr(1) = ptSt(1)
ptArr(2) = ptSt(0)
ptArr(3) = ptSt(1)
Set objPline = ThisDrawing.ModelSpace.AddLightWeightPolyline(ptArr)
objPline.ConstantWi