//获取选中对象 [TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)] public class setSelectEle : IExternalCommand { public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements) { SetSelectionElement(commandData, elements); return Result.Succeeded; } public void SetSelectionElement(ExternalCommandData commandData, ElementSet elements) { UIApplication app = commandData.Application; Document doc = app.ActiveUIDocument.Document; //获取id为729401的Element ElementId el = new ElementId(729401);
Element e = doc.GetElement(el);
Selection sel = app.ActiveUIDocument.Selection;
Transaction trans = new Transaction(doc);
trans.Start("SetSelection");
//添加到当前选择集中
sel.Elements.Add(e);
trans.Commit();
}
}
Revit 二次开发 自动选中对象,布布扣,bubuko.com
原文:http://www.cnblogs.com/siyuan926/p/3736878.html