从族实例(FamilyInstance)中取得几何对象(GeometryObject)(Revit二次开发)

几何对象(GeometryObject)

根据Revit API 文档,我们可以得到下面的结构图。
既然是几何,那就逃不过点、线、面、体、这些概念。

对应的点、线、面、体:

点: Point
线: Curve、 Edge、PolyLine、Profile
面: Face、Mesh
体: Solid
GeometryElementGeometryInstanceGeometryObject的集合。
GeometryObject也是这些类的基类。
在这里插入图片描述

几何实例(GeometryInstance)

几何实例(GeometryInstance)表示了储存在Revit中默认配置的几何组合,通过各种变换到适当的位置成为一个元素的属性。

但是并不是所有的族实例都会有几何实例(GeometryInstance)。当由于局部相连、相交、以及其他种种因素影响到实例位置时, 这种情况就不会有几何实例(GeometryInstance),而是用实体来表示几何。几何实例(GeometryInstance)中有SymbolGeometry属性,该属性是生成这个几何实例的类型的几何表示, 它使用的是局部坐标系

几何实例(GeometryInstance)也提供了一个Transform属性,表示了从类型的局部坐标系到实例的世界坐标系的坐标变换。用户有时候需要使用Transform属性对取到的几何数据进行坐标变换。

几何实例(GeometryInstance)也提供了 GetInstanceGeometry()和GetSymbolGeometry()方法来分别获取其族实例的几何元素和族类型的几何元素。

—般来说,从几何实例(GeometryInstance)中可以得到三种类型的数据:
•线(Curve):包含各种线。
•实体(Solid):包含了各种面和边。
•几何实例(Instance):另一个几何实例,用来构造本几何实例。

获取几何对象的方法

方法一

首先从族实例(FamilyInstance)中获取到它的几何元素(GeometryElement),然后从几何元素(GeometryElement)中找到其几何实例(GeometryInstance),再从几何实例(GeometryInstance)的SymbolGeometry属性中获取族类型的几何对象(GeometryObject),从族类型的几何对象(GeometryObject)中取到所有的线,然后进行坐标变换。

方法示例:

public void GetInstanceGeometry_Curve(Document doc, UIDocument uidoc)
        {
   
            TaskDialog.Show("1", "选择一个轮廓");
            Reference profilReference = uidoc.Selection.PickObject(ObjectType.Element, "请选择一个族实例轮廓");
            FamilyInstance familyInstance = doc.GetElement(profilReference) as FamilyInstance;
            Options option = new Options();//新建一个解析几何的选项
            option.ComputeReferences = true; //打开计算几何引用 
            option.DetailLevel = ViewDetailLevel.Fine; //视图详细程度为最好 
            GeometryElement geomElement = familyInstance.get_Geometry
  • 3
    点赞
  • 51
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值