GetEntity Not working after changing active document with MdiActiveDocument
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
The problem I have is that GetEntity does not work after changing active document with MdiActiveDocument.
At the end of the code you see there are 2 getentity: the first (TEST1) works, that is before the document changes.
The second (TEST2) does not work, that is before the document changes.
To try this you have to:
1) open a drawing called "BEAMS.dwg". Any drawing with that name will do.
2) Create a new drawing and choose it manually as the current active drawing.
3) Run the TestGetEntity command.
Please Help me.
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
[CommandMethod("TestGetEntity", CommandFlags.Session)]
public static void TestGetEntity()
{
// Get the current document and database
Document acDoc = Application.DocumentManager.MdiActiveDocument;
DocumentCollection acDocMgr = Application.DocumentManager;
Document acNewDoc3 = null;
bool lFound = false;
foreach (Document doc in acDocMgr)
{
string cNombre = doc.Name;
if (cNombre.Contains("BEAMS"))
{
acNewDoc3 = doc;
lFound = true;
}
}
if (lFound)
{
//THIS WORKS
PromptEntityOptions peo = new PromptEntityOptions("TEST1");
PromptEntityResult per = acDocMgr.MdiActiveDocument.Editor.GetEntity(peo);
// Set the new document current
acDocMgr.MdiActiveDocument = acNewDoc3;
//THIS DOES NOT WORK
peo = new PromptEntityOptions("TEST2");
per = acDocMgr.MdiActiveDocument.Editor.GetEntity(peo);
}
}