Revit 2011二次开发“弹出对话框,得到输入的值”
新建一个窗体FrmDlg.cs
![](https://images.cnblogs.com/cnblogs_com/greatverve/2011031101.PNG)
编辑框txtVal
按钮btnOk
调用
编辑框txtVal
按钮btnOk
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace RevitCodes
{
public partial class FrmDlg : Form
{
public string Val
{
get { return txtVal.Text; }
set { txtVal.Text = value; }
}
public FrmDlg()
{
InitializeComponent();
}
private void btnOk_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace RevitCodes
{
public partial class FrmDlg : Form
{
public string Val
{
get { return txtVal.Text; }
set { txtVal.Text = value; }
}
public FrmDlg()
{
InitializeComponent();
}
private void btnOk_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
}
}
}
#region 弹出对话框,得到输入的值
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class GetDialogValue : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
{
FrmDlg frmDlg = new FrmDlg();
frmDlg.ShowDialog();
if (frmDlg.DialogResult == DialogResult.OK)
{
MessageBox.Show("得到的值为:\n" + frmDlg.Val);
}
frmDlg.Dispose();
return Result.Succeeded;
}
}
#endregion
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class GetDialogValue : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
{
FrmDlg frmDlg = new FrmDlg();
frmDlg.ShowDialog();
if (frmDlg.DialogResult == DialogResult.OK)
{
MessageBox.Show("得到的值为:\n" + frmDlg.Val);
}
frmDlg.Dispose();
return Result.Succeeded;
}
}
#endregion
我这个博客废弃不用了,今天想寻找外链的时候,突然想到这个博客权重很高。
有需要免费外链的,留言即可,我准备把这个博客变成免费的友情链接站点。