欢迎加我的QQ群:193522571,一起来讨论、交流!

CAD中点击form上的按钮在屏幕中选择点或者其它GetXXX操作并同时Close Form的方法(getpoint close form)

using System.Windows.Forms;

namespace AutoCadWinFormDialogSample
{
    public partial class SingleButtonDialog : Form
    {
        public SingleButtonDialog()
        {
            InitializeComponent();
            button1.DialogResult = DialogResult.OK;
        }

  //将原来本应该是按钮的事件做成一个公有方法

     public void BtnOK_Click()
     {

  }
    }
}

 

 

using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using System.Windows.Forms;
using AcAp = Autodesk.AutoCAD.ApplicationServices.Application;

namespace AutoCadWinFormDialogSample
{
    public class Commands
    {
        [CommandMethod("Test")]
        public void Test()
        {
            var dlg = new SingleButtonDialog();
            var result = AcAp.ShowModalDialog(dlg);
            if (result == DialogResult.OK)
            {
                dlg.BtnOK_Click();
            }
        }
    }
}

posted @ 2018-01-19 19:25  swtool  阅读(269)  评论(0编辑  收藏  举报
欢迎加我的QQ群:193522571,一起来讨论、交流!