【问题标题】:how to make c# window form of AutoCAD plugin and AutoCAD itself available simultaneously如何使AutoCAD插件的c#窗口形式和AutoCAD本身同时可用
【发布时间】:2015-11-28 05:50:20
【问题描述】:

我已经为 AutoCAD 创建了一个基本插件。在我的插件中,一些任务正在通过 c# windows 窗体完成。我的最终用户需要在 Windows 窗体打开时访问 AutoCAD。如果 c# windows 窗体打开,当前 AutoCAD 将无法访问。要使用 AutoCAD 用户必须先关闭表单。

有没有办法同时访问 AutoCAD 和 windows 窗体?

【问题讨论】:

    标签: autocad autocad-plugin


    【解决方案1】:

    是的,您可以使用无模式表单:

    Autodesk.AutoCAD.ApplicationServices.Application.ShowModelessDialog
    

    但这不是很直观,我建议使用 PaletteSet 来承载用户控件。

    Autodesk.AutoCAD.Windows.PaletteSet ps; // declare as a STATIC variable, avoid duplicate
    ps.Add("Name here", userCtrl);
    ps.Visible = true;
    

    我更喜欢模态方式,并且在需要用户在绘图上选择某些内容的按钮内,使用 EditorUserInteraction 对象

    Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
    using (EditorUserInteraction userIt = ed.StartUserInteraction())
    {
      // this will close the form and go to the model space, once finished, the form gets back
    }
    

    【讨论】:

      猜你喜欢
      • 2012-03-08
      • 1970-01-01
      • 2016-08-28
      • 2022-09-28
      • 2011-06-28
      • 1970-01-01
      • 1970-01-01
      • 2021-07-22
      • 2018-02-20
      相关资源
      最近更新 更多