.NET

Reply
Valued Contributor
66 Posts
0 Kudos
Registered: ‎07-22-2004
Post 1 of 7

layer and LayerState Problem?

182 Views, 6 Replies
05-26-2005 01:12 AM
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#
Valued Contributor
66 Posts
0 Kudos
Registered: ‎07-22-2004
Post 2 of 7

Re: layer and LayerState Problem?

05-26-2005 01:54 AM 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.
*Albert Szilvasy
Post 3 of 7

Re: layer and LayerState Problem?

05-26-2005 08:35 AM 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#
Valued Contributor
66 Posts
0 Kudos
Registered: ‎07-22-2004
Post 4 of 7

Re: layer and LayerState Problem?

05-26-2005 05:13 PM 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?
*Albert Szilvasy
Post 5 of 7

Re: layer and LayerState Problem?

05-26-2005 06:40 PM 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?
Valued Contributor
66 Posts
0 Kudos
Registered: ‎07-22-2004
Post 6 of 7

Re: layer and LayerState Problem?

05-27-2005 06:48 PM 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?
*Albert Szilvasy
Post 7 of 7

Re: layer and LayerState Problem?

05-29-2005 10:35 AM 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?
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!