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

layer and LayerState Problem?

6 REPLIES 6
Reply
Message 1 of 7
netcai
498 Views, 6 Replies

layer and LayerState Problem?

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#
6 REPLIES 6
Message 2 of 7
netcai
in reply to: netcai

one more question:
I read some post about problem of layer mananger command and vs 2005 ,but I still don't know how to fix it. could someone explain it in detail.
thanks in advance.
Message 3 of 7
Anonymous
in reply to: netcai

1. This is normal. Thawing a layer requires a regen. The layer command does
a regen (although an optimized one that only affects the objects on the
layers that are being thawed)

2.The following works fine for me:
LayerStateManager lsm =
Application.DocumentManager.MdiActiveDocument.Database.LayerStateManager;

//restore the On/Off state and Color

lsm.RestoreLayerState("test",ObjectId.Null,0,LayerStateMasks.On |
LayerStateMasks.Color);


wrote in message news:4856968@discussion.autodesk.com...
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#
Message 4 of 7
netcai
in reply to: netcai

thanks.
1.my question is: does dot net api has a simliar method same as the method in activex ( Regen(AcRegenType.acActiveViewport) ) , I don't wish to use SendStringToExecute to do this.
2. for the second question , I have found the reason, because my code is converted from activex , in activex ,LayerStateMasks has a acAll enum, but in net api LayerStateMasks hasn't same one , so I have to combine all the enum to meet my need.
3. could you tell me how to fix the error in layer manager command?
Message 5 of 7
Anonymous
in reply to: netcai

1. No, the .net api doesn't have a regen but you can easily call the method
on the COM API.
3. You mean when running with .NET 2.0 Beta2? You need to bind acad back to
.net 1.1 (use acad.exe.config to do this). If you want to use .net 2.0
features then you are out of luck: you need to wait until the next .net 2.0
beta or ctp drop. (where they fixed the issue we are running into)

Albert
wrote in message news:4858285@discussion.autodesk.com...
thanks.
1.my question is: does dot net api has a simliar method same as the method
in activex ( Regen(AcRegenType.acActiveViewport) ) , I don't wish to use
SendStringToExecute to do this.
2. for the second question , I have found the reason, because my code is
converted from activex , in activex ,LayerStateMasks has a acAll enum, but
in net api LayerStateMasks hasn't same one , so I have to combine all the
enum to meet my need.
3. could you tell me how to fix the error in layer manager command?
Message 6 of 7
netcai
in reply to: netcai

thanks albert.
yes, I use .net 2.0 beta,I am not famliar with acad.exe.config format ,could you explain in detail how to modify it?
Message 7 of 7
Anonymous
in reply to: netcai

acad.exe.config should look like this on your machine:
----





---

After following the instructions in the comment you should have something
like this:

----





----

wrote in message news:4859405@discussion.autodesk.com...
thanks albert.
yes, I use .net 2.0 beta,I am not famliar with acad.exe.config format ,could
you explain in detail how to modify it?

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