资源简介
包含《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面板上添加一个按钮
相关资源
- CAD二次开发,边界搜索程序,自己想
- flac二次开发工具 udm工程文件
- UG二次开发所用的ugopen_v18.awx ugopen_v
- ArcEngine二次开发中AOI书签开发实现的
- UG二次开发创建曲面
- Revit导出JSON数据源代码
- 金蝶ERP二次开发(K3 BOS)应用教程
- AutoCAD .NET API进行AutoCAD二次开发基础代
- abaaqus材料二次开发-邓肯张
- 解决AUTOCAD 2019 net wizard 安装时提示未
- 周立功USBCAN二次开发套件库-供vc开发
- RevitLookup2017包含dll和addin文件
- IntersectionDemo.rar
- TC8二次开发 C API
- 二次开发威客任务平台源码 粉丝关注
- 用友API资讯管理器二次开发用的U8Lo
- 2017 Revit Lookup
- 2017 Add-In Manager
- Revit2019包含注册机.txt
- K3老单二次开发案例领料单插件开发
- 常用ENVI函数介绍
- 基于VS的ARCGIS Engine二次开发小程序,
- Samlight编程手册
- revit二次开发
- Revit to lumion插件
- ArcEngine二次开发 地图中的查询统计
- superset二次开发数据字典
- CodeSoft进行二次开发
- ACT二次开发技术.docx
- 金橙子easycad二次开发sdk 各版本MarkE
评论
共有 条评论