'可以输入任意边数:Sub Line2()Dim VarRet As Variant
Dim NewLine1 As Object
Dim NewLine2 As Object
Dim NewLine3 As Object
Dim PT1(0 To 2) As Double
Dim PT2(0 To 2) As Double
Dim PT3(0 To 2) As Double
Dim PT4(0 To 2) As Double
Dim PT5(0 To 2) As DoubleDim points(0 To 9) As Double
Dim plineObj As AcadLWPolyline
Dim i As Variant
Dim j As Variant
Dim s As Variant
Dim t As Variant- Dim k As Integer
Dim m As Variant
Dim n As Variant- Dim a
- Dim Var As Variant
- k = ThisDrawing.Utility.GetInteger("请输入边数:")
- ReDim Var(2 * k - 1) As Double
-
- i = ThisDrawing.Utility.GetInteger("请输入向内放样个数:")
- s = ThisDrawing.Utility.GetInteger("请输入向外放样个数:")
- For a = 0 To k - 1
- VarRet = Utility.GetPoint(, "Point" & Str(a) & ": ")
- Var(2 * a) = VarRet(0)
- Var(2 * a + 1) = VarRet(1)
- NextSet plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(Var)
plineObj.Closed = True
Set PlineCopy = plineObj.Copy
PlineCopy.color = acRed
ZoomAllDo
m = ThisDrawing.Utility.GetInteger("请输入向内偏移量:")
If m <= 0 Then
MsgBox "请输入正值"
Else
Exit Do
End If
LoopDo
n = ThisDrawing.Utility.GetInteger("请输入向外偏移量(-):")
If n >= 0 Then
MsgBox "请输入负值"
Else
Exit Do
End If
LoopDim offsetObj As Variant
For j = 1 To i
offsetObj = plineObj.Offset(m * j)Next j
ZoomAll
For t = 1 To s
offsetObj = plineObj.Offset(n * t)Next t
ZoomAllEnd Sub |