如何编程创建自适应族?

来源:互联网 发布:stc12单片机选型 编辑:程序博客网 时间:2024/06/15 20:49


自适应族被广大的Revit用户喻为Revit特强大的宝剑之一。关于自适应族的特性请大家看Revit的相关文档。

Revit同时也开放了API来创建自适应构件族,也可以用API来生成自适应构件对象。


Revit提供了AdaptiveComponentFamilyUtils类来处理与创建族相关的功能,提供了10多个方法。具体请看RevitAPI.chm中的说明。

下面列出了如何创建一个自适应构件族的代码。 (摘自RevitAPI.chm)

自适应族的创建于普通族很不一样,可以从代码了解创建步骤和用到的方法。



private void CreateAdaptiveComponentFamily(Document document){    // check if this family is an Adaptive Component family    if (!(AdaptiveComponentFamilyUtils.IsAdaptiveComponentFamily(document.OwnerFamily))) return;                Transaction transaction = new Transaction(document); ;    int placementCtr = 1;    ReferencePointArray refPointArray = new ReferencePointArray();    for (int i = 0; i < 10; i++)    {        transaction.SetName("Point" + i);        transaction.Start();        ReferencePoint referencePoint = document.FamilyCreate.NewReferencePoint(new XYZ(i, 0, 0));        if (i % 2 == 0)        // Even-numbered reference points will be Placement Points        {            AdaptiveComponentFamilyUtils.MakeAdaptivePoint(document, referencePoint.Id, AdaptivePointType.PlacementPoint);            transaction.Commit();            AdaptiveComponentFamilyUtils.SetPlacementNumber(document, referencePoint.Id, placementCtr);            placementCtr++;        }        else        // Odd-numbered points will be Shape Handle Points        {            AdaptiveComponentFamilyUtils.MakeAdaptivePoint(document, referencePoint.Id, AdaptivePointType.ShapeHandlePoint);            transaction.Commit();        }        refPointArray.Append(referencePoint);    }    // Create a curve running through all Reference Points    transaction.SetName("Curve");    transaction.Start();    CurveByPoints curve = document.FamilyCreate.NewCurveByPoints(refPointArray);    transaction.Commit();}


转载请复制以下信息:
原文链接: http://blog.csdn.net/joexiongjin/article/details/8476049
作者:  叶雄进 , Autodesk ADN