神仙客

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

//
获取选中对象 [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();
  }

}
posted on 2014-05-19 15:10  神仙客  阅读(1001)  评论(0编辑  收藏  举报