Revit二次开发之ExporterIFCUtils 获得墙上的柱子 墙连接的墙,闭合曲线面积

UIApplication uiapp = commandData.Application;

            UIDocument uidoc = uiapp.ActiveUIDocument;

            Document doc = uidoc.Document;

            Reference refer_1 = uidoc.Selection.PickObject(ObjectType.Element, "");

            Wall wall = doc.GetElement(refer_1) as Wall;

            Element elem_1 = doc.GetElement(refer_1);

            //获得墙上的柱子

            IList list = ExporterIFCUtils.GetAttachedColumns(wall);

            MessageBox.Show(list.Count.ToString());

            //获得墙相连的墙

            IList listData = ExporterIFCUtils.GetConnectedWalls(wall, IFCConnectedWallDataLocation.Path);

            IList listId = new List();

            foreach (IFCConnectedWallData d in listData)

            {

                Element elem = doc.GetElement(d.ElementId);

                MessageBox.Show(elem.Name);

                listId.Add(d.ElementId);

            }

            uidoc.Selection.SetElementIds(listId);

 

            //获得族实例剪切墙体留下的洞口的所有边线集合,这里假设 instance是门窗 洞口

            XYZ xyz = null;//the direction of the hole relative to the location of the curveloop

            FamilyInstance instance = elem_1 as FamilyInstance;

            CurveLoop cl = ExporterIFCUtils.GetInstanceCutoutFromWall(doc, wall, instance, out xyz);

 

            //获得闭合曲线的面积

            Solid solid = backSolid(elem_1,uiapp);

 

            IList loop = new List();

            foreach (Face face in solid.Faces)

            {

                PlanarFace pf = face as PlanarFace;

                if (pf.FaceNormal.IsAlmostEqualTo(XYZ.BasisZ))

                {

                    loop = face.GetEdgesAsCurveLoops();

                    break;

                }

            }

           double area=  ExporterIFCUtils.ComputeAreaOfCurveLoops(loop);

           MessageBox.Show((304.8*304.8*area).ToString());

 public Solid backSolid(Element elem, UIApplication uiapp)
        {
            Options option = uiapp.Application.Create.NewGeometryOptions();
            option.IncludeNonVisibleObjects = false;
            option.DetailLevel = ViewDetailLevel.Medium;
            Solid s = null;
            GeometryElement geoElement = elem.get_Geometry(option);

            foreach (GeometryObject obj in geoElement)
            {
                if (obj is Solid)
                {
                    Solid solid = obj as Solid;
                    if (solid != null)
                    {
                        s = solid;
                        break;
                    }
                }
                else if (obj is GeometryInstance)//标准族实例
                {
                    GeometryInstance geoInstance = obj as GeometryInstance;
                    GeometryElement geoElem = geoInstance.GetSymbolGeometry();
                    foreach (GeometryObject geoObj in geoElem)
                    {
                        if (geoObj is Solid && geoObj != null)
                        {
                            Solid solid = geoObj as Solid;
                            s = solid;
                            break;
                        }
                    }
                }
            }
            return s;
        }

  • 0
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值