Delete Specific entities from a selection set.

Ease of Use


Version tested with

2000i, 2004 

Submitted by:



All entities selected will be filtered and deleted 


At times you need to only delete a few entities in a group. THis macro will let you select a large number of entities and only delete the dimension entities. 


instructions for use


Option Explicit Sub DelDim() Dim ssetA As AcadSelectionSet Dim gpCode(0) As Integer Dim dataValue(0) As Variant Dim groupCode As Variant Dim dataCode As Variant gpCode(0) = 0 dataValue(0) = "Dimension" groupCode = gpCode dataCode = dataValue Set ssetA = Aset("DimDelete") ssetA.SelectOnScreen groupCode, dataCode While ssetA.Count ssetA.Highlight True ssetA.Erase ThisDrawing.Regen acActiveViewport ssetA.SelectOnScreen groupCode, dataCode Wend ssetA.Delete Set ssetA = Nothing End Sub Sub DelDimSSet() Dim mDelDimSset As AcadSelectionSet Dim mI As Integer, mTmp() As AcadEntity Dim mCntr As Long ReDim mTmp(30) If ThisDrawing.ActiveSelectionSet.Count Then For mI = ThisDrawing.ActiveSelectionSet.Count - 1 To 0 Step -1 If InStr(1, ThisDrawing.ActiveSelectionSet(mI).ObjectName, "Dimension") > 0 Then Set mTmp(mCntr) = ThisDrawing.ActiveSelectionSet.Item(mI) mCntr = mCntr + 1 If UBound(mTmp) < mCntr Then ReDim Preserve mTmp(mCntr) End If End If Next If mCntr Then ReDim Preserve mTmp(mCntr - 1) Set mDelDimSset = Aset("DimDelete") mDelDimSset.AddItems mTmp mDelDimSset.Highlight True Select Case MsgBox("Please Confirm Highlighted Entities are to be deleted.", _ vbYesNo Or vbExclamation Or vbDefaultButton1, "Confirm Deletion!") Case vbYes mDelDimSset.Erase mDelDimSset.Delete Case vbNo mDelDimSset.Delete End Select ReDim mTmp(0) Set mTmp(0) = Nothing Set mDelDimSset = Nothing End If End If ThisDrawing.Regen acActiveViewport DelDim End Sub Function Aset(iSSetName As String) As AcadSelectionSet Dim ssetA As AcadSelectionSet On Error Resume Next Set ssetA = ThisDrawing.SelectionSets.Add(iSSetName) If Err.Number <> 0 Then Set ssetA = ThisDrawing.SelectionSets(iSSetName) ssetA.Delete Set ssetA = ThisDrawing.SelectionSets.Add(iSSetName) Err.Clear End If On Error GoTo 0 Set Aset = ssetA End Function

How to use:

  1. Copy the DeletDimSSet.dvb file to a permanent location on your hard drive.
  2. Open any CAD File
  3. Click on Tools on the main menubar and from the selections click on Load Application.
  4. You are now looking at the Load/Unload Applications dialog box
  5. In the top window browse to the location where you put your DeletDimSSet.dvb file and select it.
  6. Click the Load button that is located just below the window.
  7. At the bottom of the dialog box You will get a message saying "DeletDimSSet.dvb loaded successfully"
  8. Click on the close button.
  9. Note: If you wish to view the code or alter it go to tools on the main menu click on macro then click on Visual Basic editor. You can insert a module here and paste the code in manually if you want to.

Test the code:

  1. Go back to the main tools menu and click on Macro then on Macro's
  2. In the Macros dialog box You will see The file path-Name of your file(DeletDimSSet.dvb) followed by the Module/Macro name. There will be 2 macros listed DelDim and DelDimSSet. DelDim deletes dimensions in the active selection set and asks if you want to delete more. DelDim asks for you to select a group of entities, then deltes all of the dimension.
  3. Highlight the one of the macros described above and click the Run button.
  4. DelDimSSet: Highlights all dimensions in the active selection set. Asks for verification of deletion by showing the items to be deleted. Then asks to select more if required.
  5. DelDim: Asks for the user to select entities with the standard Autocad prompt "Select Objects:" all of the object selected wil be filtered for dimensions and delte them.

Sample File:

DelDim.ZIP 7.57KB 

Approved by mdmackillop

This entry has been viewed 89 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express