One way would be:
Dim sset As AcadSelectionSet
On Error Resume Next
ThisDrawing.SelectionSets.Item("SS1").Delete
On Error GoTo 0
Set sset = ThisDrawing.SelectionSets.Add("SS1")
Registered forum members do not see this ad.
How can I detect if a selectionset with a special name exist.
I want to run the command:
Dim sset As AcadSelectionSet
Set sset = ThisDrawing.SelectionSets.Add("SS1")
but maybe,for some reason the selectionset with name "SS1" already exist in the drawing, therefore an error occurs.
any help is appreciated
One way would be:
Dim sset As AcadSelectionSet
On Error Resume Next
ThisDrawing.SelectionSets.Item("SS1").Delete
On Error GoTo 0
Set sset = ThisDrawing.SelectionSets.Add("SS1")
Thanks for your concern
I used this and it worked:
If ThisDrawing.SelectionSets.Count = 0 Then
Set sset = ThisDrawing.SelectionSets.Add("SS1")
Else
On Error Resume Next
ThisDrawing.SelectionSets.Item("SS1").Delete
On Error GoTo 0
Set sset = ThisDrawing.SelectionSets.Add("SS1")
End If
thats just using what u said.Because usually the only selectionset which may exist in the drawing is SS1, I used count method.


I find it a good approach using:
Code:Dim SS As AcadSelectionSet For Each SS In ThisDrawing.SelectionSets If SS.Name = "SS1" Then ThisDrawing.SelectionSets("SS1").Delete Exit For End If Next ThisDrawing.SelectionSets.Add ("SS1")
Registered forum members do not see this ad.
Thanks ,another nice solution
Bookmarks