领导脑瓜一拍,决定结合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 }
时间: 2024-12-23 18:46:52