how to maike an Entity IsReadEnabled?

how to maike an Entity IsReadEnabled?

Anonymous
Not applicable
625 Views
3 Replies
Message 1 of 4

how to maike an Entity IsReadEnabled?

Anonymous
Not applicable
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??
0 Likes
626 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
ent.DowngradeOpen() and ent.UpgradeOpen() can help you.
0 Likes
Message 3 of 4

Anonymous
Not applicable
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
0 Likes
Message 4 of 4

Anonymous
Not applicable
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]
0 Likes