Revit二次开发之“创建窗体执行Revit命令”
| 分类: RevitAPI(转编) |
Ribbon菜单的空间有限,因此可能需要大量控件放在一个Windows窗体里,
然后在窗体里执行Revit命令。方法就是传递参数,新建IExternalCommand
调用Execute();
然后在窗体里执行Revit命令。方法就是传递参数,新建IExternalCommand
调用Execute();
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;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DB = Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI;
namespace RevitBlog
{
public
partial class FrmCmd : Form
{
ExternalCommandData cmdDataForm;
string msgForm;
DB.ElementSet elementsForm = new DB.ElementSet();
public FrmCmd()
{
InitializeComponent();
}
//重载一个构造函数,用来传递参数
public FrmCmd(ExternalCommandData cmdData, string msg,
DB.ElementSet elements)
{
InitializeComponent();
cmdDataForm = cmdData;
msgForm = msg;
elementsForm = elements;
}
{
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WinForm = System.Windows.Forms;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB.Mechanical;
using Autodesk.Revit.UI.Selection;
using RevitApp = Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.UI.Selection;
using RevitApp = Autodesk.Revit.ApplicationServices;
namespace RevitBlog
{
//显示一个非模态窗体
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class
cmdShowForm : IExternalCommand
{
public Result Execute(ExternalCommandData cmdData, ref string msg,
ElementSet elements)
{
FrmCmd frmCmd = new FrmCmd(cmdData, msg, elements);
frmCmd.Show();
return Result.Succeeded;
}
}
//在窗体里执行Revit命令
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class
cmdFromForm : IExternalCommand
{
public Result Execute(ExternalCommandData cmdData, ref string msg,
ElementSet elements)
{
string version =
cmdData.Application.Application.VersionBuild;
version += "\n" +
cmdData.Application.Application.VersionName;
version += "\n" +
cmdData.Application.Application.VersionNumber;
TaskDialog.Show("info", version);
return Result.Succeeded;
}
}
}
{
}
前一篇:C#子窗体向父窗体传递值
后一篇:国外Revit二次开发预览

加载中…