I have written a C# plugin for AutoCAD where the user can enter some information and afterwards the appropriate drawing should be openend.
The actual workflow should be:
The problem is that I can correctly close the first window and correclty open the new drawing. Like this:
DocumentCollection documentCollection = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager;
if (File.Exists(absoultePathOfDrawing))
{
Document newDrawing = documentCollection.Open(absoultePathOfDrawing, false);
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument = newDrawing; // this sets the new drawing as the active one ==> is on top
}
Dispose(); // closes the first form
DialogResult = DialogResult.OK; // tells my applciation that the first window was successfully closed
The form closes correctly and afterwards I try to open the new form with:
if (result == DialogResult.OK)
{
MessageBox.Show("Test");
}
But now the new drawing is on top and behind is the old drawing. When I switch back to the old drawing, the new MessageBox will be shown but actually this should be shown in the new drawing, because I set the active document to the new drawing. What am I doing wrong?
I have found the solution.
I had to load my plugin with the following option:
[CommandMethod("PluginName", Autodesk.AutoCAD.Runtime.CommandFlags.Session)]
Without this my plugin is only valid in one document (the one where I started my plugin)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.