文档详情

代码revit二次开发.pdf

发布:2019-03-03约16.45万字共103页下载文档
文本预览下载声明
//============代码片段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; ListElementId selectedElem = new ListElementId(); foreach(Element elem in uiDoc.Selection.Elements) { selectedElem.Add(elem.Id); } doc.
显示全部
相似文档