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

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

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

2019-11-14 12:52:16
字體:
供稿:網(wǎng)友

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

代碼如下: (注意在執(zhí)行這個命令之前,需要先選中一些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) { // 沒有被選中的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ā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 长兴县| 休宁县| 集贤县| 扬中市| 吉水县| 西华县| 和林格尔县| 阿瓦提县| 晋江市| 天台县| 咸阳市| 仪陇县| 博野县| 南和县| 海兴县| 柞水县| 永顺县| 威海市| 应用必备| 尖扎县| 东至县| 桐梓县| 伊金霍洛旗| 娱乐| 克东县| 札达县| 中阳县| 星子县| 东安县| 桐柏县| 平原县| 罗源县| 遂川县| 高雄市| 麻栗坡县| 郁南县| 治多县| 拜泉县| 盐城市| 秭归县| 佛山市|