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

how to maike an Entity IsReadEnabled?

3 REPLIES 3
Reply
Message 1 of 4
lapiseast
282 Views, 3 Replies

how to maike an Entity IsReadEnabled?

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??
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: lapiseast

ent.DowngradeOpen() and ent.UpgradeOpen() can help you.
Message 3 of 4
lapiseast
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
Message 4 of 4
Anonymous
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]

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