Joe.... errrrrr I mean "Steve" (lol)...
Where did you get the idea that you can't purge a
frozen or locked layer?
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009
http://www.acadxtabs.com
Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm
"Steve"
wrote in message news:6102839@discussion.autodesk.com...
I'm just curious, I notice you checked for current layer but what if the layer is not empty, frozen or locked?
Joe ...
"Paul Richardson" wrote in message news:6102699@discussion.autodesk.com...
missed a 'foo'. change to match variable you use for
layername...
"Paul Richardson" wrote in message news:6102696@discussion.autodesk.com...
No need to enumerate the table as you can just check the layertable.Has() method. See
the tags use here to post so we can read you code...
[code]
{code}
using (Transaction tr =
db.TransactionManager.StartTransaction())
{
LayerTable layerTable =
(LayerTable)tr.GetObject(db.LayerTableId, OpenMode.ForRead);
//drawing may have objects that use this layer...
if ((layerTable.Has(layername) &&
layerTable[layername] != db.Clayer))
{
LayerTableRecord ltr =
(LayerTableRecord)
tr.GetObject(layerTable["foo"], OpenMode.ForRead);
if (ltr != null)
{
ltr.UpgradeOpen();
ltr.Erase();
tr.Commit();
}
}
}
{code}
[/code]
wrote in message news:6102599@discussion.autodesk.com...
This is a function i have used to delete all layers that i hv created using function createLayer() ---> private void eraseLayers() { Database db = HostApplicationServices.WorkingDatabase; Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; try { using (Transaction tran = db.TransactionManager.StartTransaction()) { LayerTable layerTable = (LayerTable)tran.GetObject(db.LayerTableId, OpenMode.ForWrite); SymbolTableEnumerator sysTabEnum = layerTable.GetEnumerator(); while (sysTabEnum.MoveNext() == true) { ObjectId objEntr = (ObjectId)sysTabEnum.Current; LayerTableRecord ltr = (LayerTableRecord)tran.GetObject(objEntr, OpenMode.ForWrite); editor.WriteMessage(" Layer Name: "+ltr.Name); ltr.Erase(); } tran.Commit(); } } catch (System.Exception e) { editor.WriteMessage("Error in iterateLayers :: " + e.Message); } }