Deleting a selectionset - COM
This was a supprise. It seems that using the Delete method on a selectionset object does not delete the selectionset but it's contents.This is intended or a bug? As it is, I can not delete selectionsets.Rune
Comments
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
Test SelectionSet methods .Clear() , .Erase() and .Delete()on both Acad and Icad platforms.
MethodDescriptionCommentIntelliCAD Object Library .Clear() Member of IntelliCAD.SelectionSet
Empties the selection set. The selection set will still exist, but will contain no items.ok .Erase() Member of IntelliCAD.SelectionSet
Empties the selection set and deletes all its members.not as documented. Does what .Delete() is supposed to do .Delete() Member of IntelliCAD.SelectionSet
Deletes the selection set and all its members.Deletes entities out of the drawing MethodDescriptionCommentAutoCAD Object Library .Clear() Member of AcadSelectionSet
The Clear method empties the selection set. The selection set will still exist,
but won't contain any items. The DWG entities that previously resided in the selection
still exist, but they no longer reside in the selection set.ok .Erase() Member of AcadSelectionSet
The Erase method deletes all items in a selection set. The selection set still
exists, but won't contain any items. The items that previously resided the selection
set get erased from the DWG.ok .Delete() Member of AcadSelectionSet
The Delete method deletes a selection set object, but not the
objects in the selection set. While the selection set itself will not exist after
the call to the Delete method, the items previously in the selection set will still exist in the DWG.ok - correspondance of methods:
Acad Icad clear <-> clear erase -> delete delete -> clear or erase Icad Acad clear <-> clear erase -> delete or clear delete -> erase - Naming issue: delete vs erase
if you query both Acad's and Icad's object library on delete it returns approx the same number of objects which implement the delete method.
if you query both Acad's and Icad's object library on erase you will find that:- Acad only implements SelectionSet.
- Icad returns approx. the same number of objects as for the delete method. These erase methods are documented in ICad COM as: "Erases the display of the entity. The entity is not deleted from the database."
- In AutoCad
theSelectionSet.delete()
method dropstheSelectionSet
from the collection of SelectionSets.
IntelliCAD's counterpart (.erase ?) doesn't:theSelectionSet
still exists in the SelectionSets collection (theSelectionSet
contains 0 items). This means IntelliCAD has no method to actually remove a SelectionSet member from the SelectionSets collection. In my view removing a SelectionSet should be handled by adding a remove method in the parent collection SelectionSets. Neither Icad nor Acad provide such a remove method on the collection SelectionSets - Following comes from AutoCad Help about delete method:
When you delete an object in a collection, all remaining items in the collection are reassigned a new index based on the current count. You should therefore avoid loops that delete an object while iterating through the collection. For example, the following VBA code will result in a runtime error:For i = 0 To ThisDrawing.Groups.Count - 1 ThisDrawing.Groups.Item(i).DeleteNext I
Instead, use the following VBA code to delete all members in a collection:For Each obj in ThisDrawing.Groups obj.DeleteNext obj
You can also use the following VBA code to delete a single member of a collection:ThisDrawing.Groups.item("group1").Delete
An error will result if you attempt to delete a collection object. - Consider following code:
Set theSelectionSet = Thisdrawing.SelectionSets.Add(sSetName)
In AutoCAD the.Add(sSetName)
method fails if a SelectionSet withsSetName
exists.
IntelliCAD is quite happy with it. The objecttheSelectionSet
will always be returned. However users should be aware that the returned object could contain items from a previous entitity selection. Applying atheSelectionSet.clear
will empty any previously selected entities.
0 - correspondance of methods:
-
In my view removing a SelectionSet should be handled by adding a remove method in the parent collection SelectionSetsI dissagree. Removing an item from it's parent object breaks with the object model of both Intellicad/BricsCad and AutoCAD. Objects such as block, dictionary, layer, linetype, layout, ucs and view are all deleted with a delete method on the object itself, not it's parent object.This also goes for all graphical entities. There are no remove methods on the modelspace, block or layout objects.
0 -
In my reply above, the first section is a qupte from the reply from Ferdinand Janssens de Bisthoven. It didn't come out the way I planned."In my view removing a SelectionSet should be handled by adding a remove method in the parent collection SelectionSets"
0