Revitの要素のパラメータ値を取得
4224 ワード
Revit二次開発基盤は、VSを使用して開発され、その要素の1つを取得するには、コードを参照してください.
選択した要素を見つけると、その属性、パラメータを取得できます.
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 document
UIDocument uidoc = commandData.Application.ActiveUIDocument;
//Get the element selection of current document
Selection 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 += "
\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;
}
}
}
選択した要素を見つけると、その属性、パラメータを取得できます.