.NET

Reply
Active Member
8 Posts
0 Kudos
Registered: ‎09-21-2006
Post 1 of 4

how to maike an Entity IsReadEnabled?

87 Views, 3 Replies
09-22-2006 12:04 AM
Entity ent = null ;
ent =(Entity)obj ; //as known,now,ent.IsReadEnabled=true and ent.IsWriteEnabled=true
...
...
//now,after use ent done ,we'll find ent.IsReadEnabled=false and ent.IsWriteEnabled=false

question: how to make ent.IsReadEnabled or ent.IsWriteEnabled true again??
Distinguished Contributor
303 Posts
1 Kudo
Registered: ‎09-26-2004
Post 2 of 4

Re: how to maike an Entity IsReadEnabled?

09-22-2006 01:50 AM in reply to: lapiseast
ent.DowngradeOpen() and ent.UpgradeOpen() can help you.
Active Member
8 Posts
0 Kudos
Registered: ‎09-21-2006
Post 3 of 4

Re: how to maike an Entity IsReadEnabled?

09-22-2006 01:55 AM in reply to: lapiseast
downgradeopen() must be used while ent is open for write(means ent.IsWriteEnabled=true);
upgradeopen() must be used while ent.IsReadEnabled=true;
but while ent.IsReadEnabled is false,how to make it true ? Message was edited by: lapiseast
Distinguished Contributor
303 Posts
1 Kudo
Registered: ‎09-26-2004
Post 4 of 4

Re: how to maike an Entity IsReadEnabled?

09-22-2006 02:10 AM in reply to: lapiseast
I do not understand your's problem. Try this code:
[code]
// Define Command "TestOpen"
[CommandMethod("TestOpen")]
static public void TestOpen()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;

PromptEntityResult rse = ed.GetEntity("\nSelect Entity: ");
if (rse.Status == PromptStatus.OK)
{
using (Transaction tr = doc.TransactionManager.StartTransaction())
{
Entity ent = (Entity) tr.GetObject(rse.ObjectId,OpenMode.ForRead);
ed.WriteMessage("\nent.IsReadEnabled = {0}",ent.IsReadEnabled);
ed.WriteMessage("\nent.IsWriteEnabled = {0}",ent.IsWriteEnabled);
ent.UpgradeOpen();
ed.WriteMessage("\nent.IsReadEnabled = {0}",ent.IsReadEnabled);
ed.WriteMessage("\nent.IsWriteEnabled = {0}",ent.IsWriteEnabled);
ent.DowngradeOpen();
ed.WriteMessage("\nent.IsReadEnabled = {0}",ent.IsReadEnabled);
ed.WriteMessage("\nent.IsWriteEnabled = {0}",ent.IsWriteEnabled);
tr.Commit();
}
}
}
[/code]
Results:
[code]
Command: testopen
Select Entity:
ent.IsReadEnabled = True
ent.IsWriteEnabled = False
ent.IsReadEnabled = True
ent.IsWriteEnabled = True
ent.IsReadEnabled = True
ent.IsWriteEnabled = True
[/code]
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post