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();
}
}
}
}