加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

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

(2016-10-13 17:12:17)
标签:

365

it

分类: Revit二次开发
            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

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有