国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

Revit API 開發(fā) (2): 顯示選中的圖元(element)

2019-11-14 12:24:06
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

*如何創(chuàng)建一個(gè)Revit AddIn 項(xiàng)目參考:Revit API 開發(fā) (1): Hello World 1. 重載IExternalCommandExecute方法。 2. 通過(guò)UIapplication.ActiveUIDocument.Selection.GetElementIds() 得到被選中的elementId。 3. 創(chuàng)建一個(gè).addin文件,參考Revit API 開發(fā) (1): Hello World 。

代碼如下: (注意在執(zhí)行這個(gè)命令之前,需要先選中一些elements。)

using System;using Autodesk.Revit;using Autodesk.Revit.DB;using Autodesk.Revit.UI.Selection;using Autodesk.Revit.UI;using Autodesk.Revit.Attributes;using System.Collections.Generic;namespace Revit_Snippets{ [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.ReadOnly)] public class Document_Selection : IExternalCommand { public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { try { // 得到當(dāng)前文檔的句柄。注意commandData通常是我們和Revit交互的中介。 UIDocument uidoc = commandData.Application.ActiveUIDocument; // 得到當(dāng)前的選擇集,然后從選擇集中得到已經(jīng)選中的element id。 Selection selection = uidoc.Selection; ICollection<ElementId> selectedIds = uidoc.Selection.GetElementIds(); if (0 == selectedIds.Count) { // 沒(méi)有被選中的element。 TaskDialog.Show("Revit","You haven't selected any elements."); } else { // 打印所有選中element的id。 String info = "Ids of selected elements in the document are: "; foreach (ElementId id in selectedIds) { info += "/n/t" + id.IntegerValue; } TaskDialog.Show("Revit",info); } } catch (Exception e) { message = e.Message; return Autodesk.Revit.UI.Result.Failed; } return Autodesk.Revit.UI.Result.Succeeded; } }}
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 朝阳市| 华容县| 永年县| 峨山| 仁怀市| 伊吾县| 北海市| 固阳县| 郁南县| 襄城县| 利津县| 梅州市| 石首市| 铜山县| 娄烦县| 专栏| 荆门市| 中超| 漯河市| 喀什市| 大关县| 南江县| 福泉市| 大连市| 万宁市| 南溪县| 任丘市| 武宁县| 兴山县| 古浪县| 浦城县| 辛集市| 游戏| 景谷| 南宁市| 育儿| 广河县| 巴青县| 太仓市| 奉贤区| 班玛县|