Sub mianyu() Dim p1 As Variant '端点坐标 Dim p2 As Variant Dim l() As Double Dim temp(1 To 2) As AcadPolyline p1 = ThisDrawing.Utility.GetPoint(, "输入点:") z = 0 p1(2) = z ReDim l(0 To 2) l(0) = p1(0) l(1) = p1(1) l(2) = z On Error GoTo Err_Control Do p2 = ThisDrawing.Utility.GetPoint(p1, vbCr & "输入下一点:") z = 0 p2(2) = z lub = UBound(l) ReDim Preserve l(lub + 3) For i = 1 To 3 l(lub + i) = p2(i - 1) Next i If lub > 3 Then templ.Delete End If Set templ = ThisDrawing.ModelSpace.AddPolyline(l) p1 = p2 Loop Err_Control: Set temp2 = ThisDrawing.ModelSpace.AddPolyline(l) Dim regions As Variant regions = ThisDrawing.ModelSpace.AddRegion(temp) End Sub |