注意由于这些对象在类型库中的定义方式,ActiveX Automation 中的集合对象具有 Delete 方法。但是,不能删除集合对象(例如 ModelSpace 集合、Layers 集合和 Dictionaries 集合)。如果用户试图删除集合,会造成错误。
Sub Ch4_DeletePolyline()
' 创建多段线
Dim lwpolyObj As AcadLWPolyline
Dim vertices(0 To 5) As Double
vertices(0) = 2: vertices(1) = 4
vertices(2) = 4: vertices(3) = 2
vertices(4) = 6: vertices(5) = 4
Set lwpolyObj = ThisDrawing.ModelSpace. _
AddLightWeightPolyline(vertices)
ZoomAll
' 删除多段线
lwpolyObj.Delete
ThisDrawing.Regen acActiveViewport
End Sub