国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 都兰县| 玛曲县| 什邡市| 扬中市| 宁明县| 石河子市| 蓬溪县| 富顺县| 龙里县| 闽侯县| 宜宾县| 宁夏| 什邡市| 同德县| 黎川县| 五指山市| 龙江县| 浙江省| 皋兰县| 滕州市| 城口县| 启东市| 宝清县| 万盛区| 宁德市| 民乐县| 盐津县| 吉安县| 汝南县| 金沙县| 右玉县| 来安县| 五峰| 安国市| 繁峙县| 乌海市| 阿克| 东平县| 伊金霍洛旗| 兰坪| 巨鹿县|