如何编程创建自适应构件对象?

来源:互联网 发布:数据库导论 需要的基础 编辑:程序博客网 时间:2024/06/05 17:41


在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;    }}

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



原创粉丝点击