自适应族

    xiaoxiao2021-03-26  61

    http://blog.csdn.net/joexiongjin/article/details/8476049      如何编程创建自适应族?

    自适应族被广大的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/8476184

    在Revit里面创建普通族实例大家不陌生,用NewFamilyInstance函数即可。这个函数有10来个重载形式,可以创建各种族实例。

    在有自适应构件的模型里,我们用RevitLookup查看自适应构件的Location属性为空。(普通族实例的Location属性不会为空,或是一个LocationPoint,或者为LocationLine)。这个开发者带来困惑,我们如何编程创建自适应构件的实例呢?

    解决:

    Revit给自适应构件提供了另一个类来生成自适应族,以及生成自适应构件对象。

    就如何生成自适应族,我写了一篇相关博文,

    这里说些如何创建自适应构件对象。AdaptiveComponentInstanceUtils 类提供了10个方法用于创建构件。每一个方法的说明请看RevitAPI.chm文件(Revit2012 以上)

    下面的代码演示了如何创建自适应构件实例。

    先创建一个对象,然后为每一个点设置坐标。 private void CreateAdaptiveComponentInstance(Document document, FamilySymbol symbol)   {       // Create a new instance of an adaptive component family       FamilyInstance instance = AdaptiveComponentInstanceUtils.CreateAdaptiveComponentInstance(document, symbol);          // Get the placement points of this instance       IList<ElementId> placePointIds = new List<ElementId>();       placePointIds = AdaptiveComponentInstanceUtils.GetInstancePlacementPointElementRefIds(instance);       double x = 0;          // Set the position of each placement point       foreach (ElementId id in placePointIds)       {           ReferencePoint point = document.GetElement(id) as ReferencePoint;           point.Position = new Autodesk.Revit.DB.XYZ(10*x, 10*Math.Cos(x), 0);           x += Math.PI/6;       }   }   revit自适应点的解释    http://wenku.baidu.com/link?url=6kxYBwx09Y_O9mpm5IRUiCKZyS3HG3_hpXhThvXO0llLC-8eb4i2odAEGL9aTyied9lIDxAvMguz5i3C9wbzIdvW_f0tTPUw3iN_lddA4wK
    转载请注明原文地址: https://ju.6miu.com/read-662109.html

    最新回复(0)