Message 1 of 7
layer and LayerState Problem?

Not applicable
05-26-2005
01:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
question 1:
I want turn on ,unlock,unfrozen all layer,the following is my code,but question is when run the code , the entity are all despeared, i have to regen the drawing and the entity could visible.
Database curdb;
Autodesk.AutoCAD.DatabaseServices.TransactionManager tm;
Transaction myT
curdb = Application.DocumentManager.MdiActiveDocument.Database;
tm = curdb.TransactionManager;
using (myT = tm.StartTransaction())
{
LayerTable lt = (LayerTable)tm.GetObject(curdb.LayerTableId, OpenMode.ForRead);
foreach (ObjectId objId in lt)
{
LayerTableRecord ltr = (LayerTableRecord)tm.GetObject(objId, OpenMode.ForWrite);
if (ltr.IsLocked) { ltr.IsLocked = false; }
if (ltr.IsFrozen) { ltr.IsFrozen = false; }
if (ltr.IsOff) { ltr.IsOff = false; }
}
myT.Commit();
}
question 2:
I can save layerstate,but I can't restore it, I wonder my problem is i don't know the use of parmeter: undefinedlayerstatepolicy. could anyone show me some code of how to use RestoreLayerState method in c#
I want turn on ,unlock,unfrozen all layer,the following is my code,but question is when run the code , the entity are all despeared, i have to regen the drawing and the entity could visible.
Database curdb;
Autodesk.AutoCAD.DatabaseServices.TransactionManager tm;
Transaction myT
curdb = Application.DocumentManager.MdiActiveDocument.Database;
tm = curdb.TransactionManager;
using (myT = tm.StartTransaction())
{
LayerTable lt = (LayerTable)tm.GetObject(curdb.LayerTableId, OpenMode.ForRead);
foreach (ObjectId objId in lt)
{
LayerTableRecord ltr = (LayerTableRecord)tm.GetObject(objId, OpenMode.ForWrite);
if (ltr.IsLocked) { ltr.IsLocked = false; }
if (ltr.IsFrozen) { ltr.IsFrozen = false; }
if (ltr.IsOff) { ltr.IsOff = false; }
}
myT.Commit();
}
question 2:
I can save layerstate,but I can't restore it, I wonder my problem is i don't know the use of parmeter: undefinedlayerstatepolicy. could anyone show me some code of how to use RestoreLayerState method in c#