本文主要是介绍获取Revit中的一个元素的参数值,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Revit二次开发基础,使用VS对其进行开发,要获取其中的一个元素,可以参考一下代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System.Windows.Media.Imaging;namespace Document_Selection
{[Autodesk.Revit.Attributes.Transaction(TransactionMode.ReadOnly)]public class Document_selection:IExternalCommand{public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements){try{//Select some elements in Revit before invoking this command//Get the handle of current documentUIDocument uidoc = commandData.Application.ActiveUIDocument;//Get the element selection of current documentSelection selection = uidoc.Selection;ElementSet collection = selection.Elements;if (0 == collection.Size){//如果没有元素被选中TaskDialog.Show("Revit", "you have not seleced any elements");}else{String info = "Ids if selected elements in the document aer:";foreach (Element elem in collection){info += "\n\t" + elem.Id.IntegerValue;}TaskDialog.Show("Revit", info);}}catch (Exception e){message = e.Message;return Autodesk.Revit.UI.Result.Failed;}return Autodesk.Revit.UI.Result.Succeeded;}}
}
找到被选中的元素,就可以获取其属性,参数。
这篇关于获取Revit中的一个元素的参数值的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!