Selection set deleting not working

Selection set deleting not working

Anonymous
Not applicable
298 Views
4 Replies
Message 1 of 5

Selection set deleting not working

Anonymous
Not applicable
Hi,

I'm trying to create a selection set, and if allready existing, delete and
recreate it, with error trapping.
The line in the Else statement doesn't seem to work, and gives no error...


Dim ssetObj As AcadSelectionSet, ssName As String
On Error Resume Next
Set ssetObj = ThisDrawing.SelectionSets.Add("TEST")
If Err.Number = 0 Then
MsgBox ("Sset created")
Else
MsgBox (Err.Description)
ssetObj.Delete

Set ssetObj = ThisDrawing.SelectionSets.Add("TEST")
End If
0 Likes
299 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Do you get a messagebox with the description when the Else clause runs?

"Yves" wrote in message
news:5314464@discussion.autodesk.com...
Hi,

I'm trying to create a selection set, and if allready existing, delete and
recreate it, with error trapping.
The line in the Else statement doesn't seem to work, and gives no error...


Dim ssetObj As AcadSelectionSet, ssName As String
On Error Resume Next
Set ssetObj = ThisDrawing.SelectionSets.Add("TEST")
If Err.Number = 0 Then
MsgBox ("Sset created")
Else
MsgBox (Err.Description)
ssetObj.Delete

Set ssetObj = ThisDrawing.SelectionSets.Add("TEST")
End If
0 Likes
Message 3 of 5

Anonymous
Not applicable
Try this:

Dim ssetObj As AcadSelectionSet, ssName As String

On Error Resume Next
Set ssetObj = ThisDrawing.SelectionSets.Item("TEST")
If Err Then
Err.Clear
Set ssetObj=ThisDrawing.SelectionSets.Add("TEST")
Else
ssetObj.Clear
End If
0 Likes
Message 4 of 5

Anonymous
Not applicable

Here's a good sample that I've always
used:


Dim ssetObj As
AcadSelectionSet

On Error Resume
Next
If Not IsNull(ThisDrawing.SelectionSets.Item("TEST_SSET"))
Then
    Set ssetObj =
ThisDrawing.SelectionSets.Item("TEST_SSET")
   
ssetObj.Delete
End If
Set ssetObj =
ThisDrawing.SelectionSets.Add("TEST_SSET")


face=Arial>---
T.W.Tan
0 Likes
Message 5 of 5

Anonymous
Not applicable

Hi,

 

Thanks all to the ideas,

 

Finally I shut down Autocad yesterday, and this
morning my code that was suppose to work, is working!!!

 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">


Here's a good sample that I've always
used:


Dim ssetObj As
AcadSelectionSet

On Error Resume
Next
If Not IsNull(ThisDrawing.SelectionSets.Item("TEST_SSET"))
Then
    Set ssetObj =
ThisDrawing.SelectionSets.Item("TEST_SSET")
   
ssetObj.Delete
End If
Set ssetObj =
ThisDrawing.SelectionSets.Add("TEST_SSET")


face=Arial>---
T.W.Tan
0 Likes