资源简介
包含《Autodesk Revit 二次开发基础教程》所有示例代码片段,方便初学者免去重新敲代码的麻烦。
代码片段和文件信息
//============代码片段2-1:外部命令中Excute函数的定义============
public interface IExternalCommand
{
public Autodesk.Revit.UI.Result Execute(
Autodesk.Revit.UI.ExternalCommandData commandData
ref string message
Autodesk.Revit.DB.ElementSet elements)
}
//============代码片段2-2:从commandData中取到Document============
UIApplication uiApplication = commandData.Application;
Application application = uiApplication.Application;
UIDocument uiDocument = uiApplication.ActiveUIDocument;
Document document = uiDocument.Document;
//============代码片段2-3:使用message参数============
public class command : IExternalCommand
{
public Result Execute(
ExternalCommandData commandData
ref string message
ElementSet elements)
{
message = “message test“;
return Result.Failed;
}
}
//============代码片段2-4:使用element参数============
public Result Execute(ExternalCommandData commandData ref string message ElementSet elements)
{
message = “Please take attention on the highlighted Walls!“;
//先从UI选取元素,然后执行该插件
ElementSet elems = commandData.Application.ActiveUIDocument.Selection.Elements;
foreach (Element elem in elems)
{
Wall wall = elem as Wall;
if (null != wall)
{
elements.Insert(elem);
}
}
return Result.Failed;
}
//============代码片段2-5:外部命令中Excute函数的返回值============
public Result Execute(ExternalCommandData commandData ref string message ElementSet elements)
{
try
{
UIDocument uiDoc = commandData.Application.ActiveUIDocument;
Document doc = uiDoc.Document;
List selectedElem = new List();
foreach(Element elem in uiDoc.Selection.Elements)
{
selectedElem.Add(elem.Id);
}
doc.Delete(selectedElem);
TaskDialogResult result = TaskDialog.Show(
“Revit“
“Yes to return succeeded and delete all selection“+
“No to cancel all commands.“
TaskDialogCommonButtons.Yes|TaskDialogCommonButtons.No);
if (TaskDialogResult.Yes == result)
{
return Result.Succeeded;
}
else if (TaskDialogResult.No == result)
{
elements = uiDoc.Selection.Elements;
message = “Failed to delete selection.“;
return Result.Failed;
}
else
{
return Result.Cancelled;
}
}
catch
{
message = “Unexpected Exception is thrown out.“;
return Result.Failed;
}
}
//============代码片段2-6:IExternalApplication接口定义============
public interface IExternalApplication
{
Autodesk.Revit.UI.Result OnShutdown(UIControlledApplication application);
Autodesk.Revit.UI.Result onstartup(UIControlledApplication application);
}
//============代码片段2-7:使用IExternalApplication定制UI============
public Autodesk.Revit.UI.Result onstartup(UIControlledApplication application)
{
//添加一个新的Ribbon面板
RibbonPanel ribbonPanel = application.CreateRibbonPanel(“NewRibbonPanel“);
//在新的Ribbon面板上添加一个按钮
相关资源
- 地图浏览(ArcEngine)
-
AutoCAD ob
jectARX二次开发实例-状态栏 - 在delphi7下进行autocad二次开发的一个简
- 金蝶ERP二次开发技术手册
- 海康sdk说明书 二次开发参考
- AutoCAD二次开发在直齿圆柱齿轮参数化
- 用友二次开发资料含
- Revit2018帮助文档、lookup及外部加载工
- Revit二次开发源码大全之二
- bim 门窗族汇总更新
- Revit桥梁族
- 光阵通用高拍仪控件
- 精伦IDR210 IDR200 2016年最新4.1通用二次
- 2018revit二次开发论文参考
- revit法院模型
- lisp源代码 ***工具箱代码 cad二次开发
- 精伦身份证阅读器通用二次开发SDK
- 武汉精伦身份证阅读器的二次开发包
- LED显示屏二次开发接口的设计方案
- AUTOCAD二次开发零件自动拆图自动标注
- 海康相机SDK二次开发与Halcon混合编程
- 海康相机SDK二次开发与Qt混合编程代码
- 1 AutoCAD .NET开发指南2012版》.rar
- Revit 模型一键输出 3D Tiles (for Cesiu
- catia二次开发论文
- HIKVISION工业相机的SDK二次开发的QT
- Dynamo开发手册
- OpenDwg开发文档
- QGIS2.8.9二次开发包及其桌面程序
- ArcEgine开发实战资料
评论
共有 条评论