can t delet selectionset

can t delet selectionset

Anonymous
Not applicable
383 Views
4 Replies
Message 1 of 5

can t delet selectionset

Anonymous
Not applicable
Hello
it drives me crazy ...
i want to check if selection set already exist , if yes then delete it. but it seems it works not every time. after the second time i can t create the selectionset. acad says its already exist.
here my code

Dim ssetObj As AcadSelectionSet
Dim ssetObj2 As AcadSelectionSet
Dim ObjSS As AcadSelectionSet

For Each ObjSS In ThisDrawing.SelectionSets
Debug.Print ObjSS.Name
If UCase("Regio_SSET") = UCase(ObjSS.Name) Or UCase("Subt_SSET") = UCase(ObjSS.Name) Then
ThisDrawing.SelectionSets.Item(anzi).Delete
End If
anzi = anzi + 1
Next

Set ssetObj = ThisDrawing.SelectionSets.Add("Regio_SSET")
.....
0 Likes
384 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
take a look at my respond here
http://discussion.autodesk.com/thread.jspa?threadID=103847
0 Likes
Message 3 of 5

Anonymous
Not applicable
huii, that should go in acad help

thank you!
Tom
0 Likes
Message 4 of 5

Anonymous
Not applicable
Hi TOM!

NEVER delete an entity of the loop while being in a FOR EACH!
You have to set a marker inside the loop and then (after then Next-Statment)
delete the marked entity!

(And if you use "OPTION COMPARE TEXT" before your sub you need not use UCASE
.....)

...
ssMarker = false
for each sset in Thisdrawing.Selectionsets
if sset.name = "regio_sset" then ssMarker = true
next

if ssMarker then Thisdrawing.Selectionsets("regio_sset").Delete
...




wrote in message news:5434663@discussion.autodesk.com...
Hello
it drives me crazy ...
i want to check if selection set already exist , if yes then delete it. but
it seems it works not every time. after the second time i can t create the
selectionset. acad says its already exist.
here my code

Dim ssetObj As AcadSelectionSet
Dim ssetObj2 As AcadSelectionSet
Dim ObjSS As AcadSelectionSet

For Each ObjSS In ThisDrawing.SelectionSets
Debug.Print ObjSS.Name
If UCase("Regio_SSET") = UCase(ObjSS.Name) Or UCase("Subt_SSET") =
UCase(ObjSS.Name) Then
ThisDrawing.SelectionSets.Item(anzi).Delete
End If
anzi = anzi + 1
Next

Set ssetObj = ThisDrawing.SelectionSets.Add("Regio_SSET")
.....
0 Likes
Message 5 of 5

Anonymous
Not applicable
I do not agree
Why to not use Exit For instead of marker?
Somethink like this:

ssName = "regio_sset"
for each sset in Thisdrawing.Selectionsets
if sset.name = ssName then
sset.Delete
Exit For
next

Regards,

~'J'~
0 Likes