if ((layerTable.Has(NombreCapa) && layerTable[NombreCapa] != db.Clayer)) //Clayer significa current layer, no se puede eliminar una capa que sea actual. { //eliminamos todas las entidades de la capa. Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection entidades = FunctionsCapas.GetEntitiesOnLayer(NombreCapa); if (entidades.Count > 0) { foreach (ObjectId ent in entidades) { Autodesk.AutoCAD.DatabaseServices.DBObject obj = tr.GetObject(ent, OpenMode.ForWrite); obj.Erase(); } } //una vez eliminados todas las entidades, eliminamos la capa LayerTableRecord ltr = (LayerTableRecord) tr.GetObject(layerTable[NombreCapa], OpenMode.ForRead); if (ltr != null) { ltr.UpgradeOpen(); ltr.Erase(); } }//end if Sí es la capa
Hi.
I would like to have a function like look "laydel" command.
I use layer name (NombreCapa) as parameter but my method in some cases is very slow.
I don´t check if some entity can´t be delete, because all entities that I use within that layer will be circles.
Are there any methods faster than mine?
Thanks in advance.
GetEntitiesOnLayer() is a method of the same blog:
http://through-the-interface.typepad.com/through_the_interface/2007/08/moving-entities.html
In this case, it´s for change all layer from one layer to other layer.
Yes, Before you delete a layer, you should decide what to do with those objects that draw on this layer? It is not that those objects could or could not be delete, but that when a layer has objects on it, just deleting this layer may cause problems.
if you would like to delete the objects as well, i suggest you just delete all the objects that within this layer and use Purge to delete the layer, i think this way sounds better.