Revit API判断是不是柱族模板

本文介绍了一个Revit API命令,用于验证当前打开的文档是否为族文档,并判断其是否使用了族模板,同时检查族类别的匹配情况。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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://www.cnblogs.com/greatverve/p/ValidateDocument.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值