Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
Here is my vba code to select all the circles with a radius of 1.9433 and delete. Unfortunately, it deletes all the circles, even the ones which don't match the specified radius. Any help to resolve this is very much appreciated. Thank you.
Sub DeleteAllSelectedCircles()
' Declare variables
Dim acadApp As Object
Dim acadDoc As Object
Dim selectionSet As Object
Dim filterType(1) As Integer
Dim filterData(1) As Variant
' Get the AutoCAD application and active document
Set acadApp = GetObject(, "AutoCAD.Application")
Set acadDoc = acadApp.ActiveDocument
' Create a new selection set
On Error Resume Next
Set selectionSet = acadDoc.SelectionSets.Add("CircleSelectionSet")
If Err.Number <> 0 Then
Set selectionSet = acadDoc.SelectionSets.Item("CircleSelectionSet")
Err.Clear
End If
On Error GoTo 0
' Define the filter for circles
filterType(0) = 0
filterData(0) = "CIRCLE"
filterType(1) = 40 ' Radius property
filterData(1) = 1.9433
' Select all circles in the drawing
selectionSet.Select acSelectionSetAll, , , filterType, filterData
' Delete the selected circles
Dim entity As Object
For Each entity In selectionSet
entity.Delete
Next entity
' Inform the user
MsgBox selectionSet.Count & " circles deleted."
End Sub
-NT
Solved! Go to Solution.