神仙客

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

领导脑瓜一拍,决定结合Revit开发产品,俺可惨了,两眼一抹黑,在他拍脑袋前,俺连Revit是什么、干嘛用的都不知道,硬着头皮上吧。老了,脑瓜不好使了,学过的在这里做个笔记

 1 //获取选中对象
 2 
 3 [TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
 4 public class getSelectEle : IExternalCommand
 5 {
 6 
 7     public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
 8     {
 9           GetSelectionElement(commandData, elements);
10            return Result.Succeeded;
11     }
12 
13 
14     public void GetSelectionElement(ExternalCommandData   commandData, ElementSet elements)
15     {
16         UIApplication app = commandData.Application;
17         Selection sel = app.ActiveUIDocument.Selection;
18         ElementSet es = sel.Elements;
19         if (es.Size > 0)
20         {
21             string seleStr = "";
22             foreach (Element selitem in es)
23             {
24                 seleStr += selitem.Id + "," + selitem.Name + "\n";
25             }  
26             TaskDialog.Show("all Selection", seleStr);
27         }
28 
29      } 
30 }                       

 

posted on 2014-05-19 14:39  神仙客  阅读(1033)  评论(0编辑  收藏  举报