博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Revit API判断是不是柱族模板
阅读量:7024 次
发布时间:2019-06-28

本文共 1221 字,大约阅读时间需要 4 分钟。

OwnerFamily即族模板。
获取类别的方法:
Document.Settings.Categories.get_Item(BuiltInCategory.OST_Columns);
//
判断是不是柱族模板
[TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public 
class cmdCheckFamily : IExternalCommand
{
    
bool ValidateDocument(Document rvtDoc)
    {
        
if (!rvtDoc.IsFamilyDocument)
//
判断是不是族文档
        {
            TaskDialog.Show(
"
Family API
"
"
This command works only in the family editor.
");
            
return 
false;
        }
        Family ownerFamily = rvtDoc.OwnerFamily;
        
if (ownerFamily == 
null)
//
判断是否使用了族模板
        {
            TaskDialog.Show(
"
Family API
"
"
This document does not have Owner Family.
");
            
return 
false;
        }
        
//
取得族类别的方法
        Category catColumn = rvtDoc.Settings.Categories.get_Item(BuiltInCategory.OST_Columns);
        
if (!ownerFamily.FamilyCategory.Id.Equals(catColumn.Id))
        {
            TaskDialog.Show(
"
Family API
"
"
The category of this document does not match the context of this commands. Please open Metric Column.rft
");
            
return 
false;
        }
        
return 
true;
    }
    
public Result Execute(ExternalCommandData commandData, 
ref 
string messages, ElementSet elements)
    {
        UIApplication app = commandData.Application;
        Document doc = app.ActiveUIDocument.Document;
        Selection sel = app.ActiveUIDocument.Selection;
        ValidateDocument(doc);
        
return Result.Succeeded;
    }
}
url:

转载地址:http://jnsxl.baihongyu.com/

你可能感兴趣的文章
linux下串口控制
查看>>
马尔科夫链简介
查看>>
VC++ 的MFC 和ATL 及COM 是什么?
查看>>
.NET泛型04,使用Lazy<T>实现延迟加载
查看>>
ASP.NET MVC中的Session以及处理方式
查看>>
想知道美国大学按计算机专业的排名,以及各大学在计算机哪个方面是强项,应该去哪里查找?...
查看>>
[C# 网络编程系列]专题六:UDP编程
查看>>
DNGuard 使用介绍
查看>>
HDU 4419 Colourful Rectangle(线段树)
查看>>
webservice接口的开发和调用
查看>>
Z-order curve
查看>>
用Excel打开csv格式文件并生成相应图形
查看>>
【uTenux实验】内存池管理(固定内存池和可变内存池)
查看>>
Android——Android Studio的一些小技巧(转)
查看>>
Linux Linux程序练习二
查看>>
angular run()运行块
查看>>
如何检测NFC芯片型号?NFC手机即可!
查看>>
Android 8款开源游戏引擎
查看>>
如何推断一个P2P平台是否靠谱?
查看>>
Spring学习【Spring概述】
查看>>