Revit二次开发之“取得内参BuiltIn名称的方法”
有时候你需要知识某个元素类别对应的内参名称是什么,是取得名称的方法。
from:http://revit.5d6d.com/thread-1261-1-1.html
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WinForm = System.Windows.Forms;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB.Mechanical;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.DB.Structure;
using System.Xml;
namespace RevitCodes
{
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class cmdBuiltIn : IExternalCommand
{
public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elements)
{
UIDocument uiDoc = cmdData.Application.ActiveUIDocument;
Transaction ts = new Transaction(uiDoc.Document, "delete");
ts.Start();
Element selectedElement = null;
//需要首先选择一个元素
foreach (Element e in uiDoc.Selection.Elements)
{
selectedElement = e;
break;//取得一个测试
}
Category category = selectedElement.Category;
//取得类别内参名的方法
BuiltInCategory enumCategory = (BuiltInCategory)category.Id.IntegerValue;
TaskDialog.Show("builtin", enumCategory.ToString());//风管对应OST_DuctCurves
ts.Commit();
return Result.Succeeded;
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WinForm = System.Windows.Forms;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB.Mechanical;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.DB.Structure;
using System.Xml;
namespace RevitCodes
{
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class cmdBuiltIn : IExternalCommand
{
public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elements)
{
UIDocument uiDoc = cmdData.Application.ActiveUIDocument;
Transaction ts = new Transaction(uiDoc.Document, "delete");
ts.Start();
Element selectedElement = null;
//需要首先选择一个元素
foreach (Element e in uiDoc.Selection.Elements)
{
selectedElement = e;
break;//取得一个测试
}
Category category = selectedElement.Category;
//取得类别内参名的方法
BuiltInCategory enumCategory = (BuiltInCategory)category.Id.IntegerValue;
TaskDialog.Show("builtin", enumCategory.ToString());//风管对应OST_DuctCurves
ts.Commit();
return Result.Succeeded;
}
}
}
我这个博客废弃不用了,今天想寻找外链的时候,突然想到这个博客权重很高。
有需要免费外链的,留言即可,我准备把这个博客变成免费的友情链接站点。