Revit二次开发之“得到对象的所属类型”
通过FamilyInstance.FamilySymbol.Family
来自:http://revit.5d6d.com/thread-830-1-3.html
end
来自:http://revit.5d6d.com/thread-830-1-3.html
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class GetElementType : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
{
UIApplication uiApp = commandData.Application;
Document doc = uiApp.ActiveUIDocument.Document;
Selection sel = uiApp.ActiveUIDocument.Selection;
Reference refelem = sel.PickObject(ObjectType.Element, "请选择一个风管");
FamilyInstance fi = refelem.Element as FamilyInstance;
MessageBox.Show(fi.Symbol.Family.Name);//得到类型名,比如天圆地方 - 角度 -法兰
MessageBox.Show(refelem.Element.GetType().Name);//得到类型,比如风管对应Duct而弯头之类却都对应FamilyInstance
return Result.Succeeded;
}
}
[Regeneration(RegenerationOption.Manual)]
public class GetElementType : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
{
UIApplication uiApp = commandData.Application;
Document doc = uiApp.ActiveUIDocument.Document;
Selection sel = uiApp.ActiveUIDocument.Selection;
Reference refelem = sel.PickObject(ObjectType.Element, "请选择一个风管");
FamilyInstance fi = refelem.Element as FamilyInstance;
MessageBox.Show(fi.Symbol.Family.Name);//得到类型名,比如天圆地方 - 角度 -法兰
MessageBox.Show(refelem.Element.GetType().Name);//得到类型,比如风管对应Duct而弯头之类却都对应FamilyInstance
return Result.Succeeded;
}
}
我这个博客废弃不用了,今天想寻找外链的时候,突然想到这个博客权重很高。
有需要免费外链的,留言即可,我准备把这个博客变成免费的友情链接站点。