Erase method example
Sub Erase_Example()
Dim pt1(0 To 2) As Double
Dim pt2(0 To 2) As Double
pt1(0) = 3: pt1(1) = 3: pt1(2) = 0
pt2(0) = 1: pt2(1) = 3: pt2(2) = 0
Dim rayObj As AcadRay
Set rayObj = ThisDrawing.ModelSpace.AddRay(pt1, pt2)
Dim points(0 To 5) As Double
points(0) = 3: points(1) = 7
points(2) = 9: points(3) = 2
points(4) = 3: points(5) = 5
Dim plineObj As AcadLWPolyline
Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
plineObj.Closed = True
pt1(0) = 0: pt1(1) = 0: pt1(2) = 0
pt2(0) = 2: pt2(1) = 2: pt2(2) = 0
Dim lineObj As AcadLine
Set lineObj = ThisDrawing.ModelSpace.AddLine(pt1, pt2)
pt1(0) = 20: pt1(1) = 30: pt1(2) = 0
Dim radius As Double: radius = 3
Dim circObj As AcadCircle
Set circObj = ThisDrawing.ModelSpace.AddCircle(pt1, radius)
Dim majAxis(0 To 2) As Double
Dim center(0 To 2) As Double
Dim radRatio As Double
center(0) = 5#: center(1) = 5#: center(2) = 0#
majAxis(0) = 10: majAxis(1) = 20#: majAxis(2) = 0#
radRatio = 0.3
Dim ellObj As AcadEllipse
Set ellObj = ThisDrawing.ModelSpace.AddEllipse(center, majAxis, radRatio)
ZoomAll
Dim oSS As AcadSelectionSet
Set oSS = ThisDrawing.ActiveSelectionSet
oSS.Clear
ReDim arrayOfObjects(0 To ThisDrawing.ModelSpace.Count - 1) As AcadEntity
Dim i As Integer
For i = 0 To ThisDrawing.ModelSpace.Count - 1
Set arrayOfObjects(i) = ThisDrawing.ModelSpace.Item(i)
Next
oSS.AddItems arrayOfObjects
MsgBox getContent(oSS)
oSS.Erase
MsgBox getContent(oSS)
Set oSS = Nothing
ThisDrawing.Application.ZoomExtents
End Sub
Private Function getContent(inSelectionSet As AcadSelectionSet) As String
Dim sBuf As String: sBuf = vbNullString
Dim i As Integer
If inSelectionSet.Count = 0 Then
sBuf = "The selection set is empty"
Else
sBuf = "The selection set contains:"
For i = 0 To inSelectionSet.Count - 1
sBuf = sBuf & vbCrLf & inSelectionSet.Item(i).ObjectName
Next
End If
getContent = sBuf
End Function
© Bricsys NV. All rights reserved. |