Revit 二次开发 元素的所有面

需要传入一个 Options的对象 打开的方式  

            Options options = new Options();
            options.ComputeReferences = true;确定是否计算对几何对象的引用
            options.IncludeNonVisibleObjects = true;是否提取未设置为可见的元素几何对象
            options.DetailLevel = ViewDetailLevel.Fine; 提取的几何图形的详细级别

 

        /// <summary>
        /// 元素的所有面
        /// </summary>
        /// <param name="item">元素</param>
        /// <param name="options">打开方式</param>
        /// <returns>所有的面</returns>
        public static List<Face> GetFaceByElement(this Element item, Options options)
        {
            List<Face> listFace = new List<Face>();
            根据打开的方式得到几何信息
            GeometryElement geometry = item.get_Geometry(options);
            
            foreach (GeometryObject geomObj in geometry)
            {
                GeometryInstance geomInstance = geomObj as GeometryInstance;
                
                if (geomInstance != null)
                {
                    foreach (GeometryObject instObj in geomInstance.GetInstanceGeometry())
                    {
                        三维的实体
                        Solid instsolid = instObj as Solid;
                        
                        if (instsolid == null || instsolid.Faces.Size == 0 || instsolid.Edges.Size == 0)
                        {
                            continue;
                        }
                        
                        foreach (Face face in instsolid.Faces)
                        {
                            listFace.Add(face);
                        }
                    }
                }
                
                Solid solid = geomObj as Solid;
                
                if (solid != null)
                {
                    if (solid.Faces.Size == 0 || solid.Edges.Size == 0)
                    {
                        continue;
                    }
                    else
                    {
                        foreach (Face face in solid.Faces)
                        {
                            listFace.Add(face);
                        }
                    }
                }
            }
            
            return listFace;
        }

 

  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值