2013-02-13 24 views
0

我已经写了AutoCAD中的C#插件,用户可以输入一些信息,之后相应的图纸应双头呆了。C#更改Windows形成以ontop的打开AutoCAD绘图

实际的工作流程应该是:

  1. 我开始我的插件在AutoCAD
  2. 用户可以输入在Windows窗体中的一些信息是当前活动绘图
  3. 当用户的顶部点击输入按钮应该打开一个新的图纸
  4. 用户输入一些信息的表格应该关闭(工作正常)
  5. 应该打开一个新的窗口窗体来输入一些其他信息(与第一个窗口不一样)但在新图纸中

问题是我可以正确关闭第一个窗口并打开新图形。就像这样:

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 

形式正确关闭,后来我尝试与打开新的形式:

if (result == DialogResult.OK) 
{ 
     MessageBox.Show("Test");   

} 

但现在的新的绘画是在上面,背后是老图。当我切换回旧图形时,将显示新的MessageBox,但实际上这应该显示在新图形中,因为我将活动文档设置为新图形。 我在做什么错?

回答

1

我已经找到了解决办法。

我不得不加载我的插件使用下列选项:

[CommandMethod("PluginName", Autodesk.AutoCAD.Runtime.CommandFlags.Session)] 

没有这个我的插件中只有一个文件(就是我开始了我的插件)

在有效
相关问题