.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

programming laydel command

2 REPLIES 2
Reply
Message 1 of 3
joantopo
449 Views, 2 Replies

programming laydel command

 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.

 

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
2 REPLIES 2
Message 2 of 3
joantopo
in reply to: joantopo

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.

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
Message 3 of 3
Anonymous
in reply to: joantopo

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost