public double GetWallCutArea(
            FamilyInstance fi,
            Wall wall)
        {
            Document doc = fi.Document;

            XYZ cutDir = null;

            CurveLoop curveLoop
                = ExporterIFCUtils.GetInstanceCutoutFromWall(
                      fi.Document, wall, fi, out cutDir);

            IList <CurveLoop> loops = new List <CurveLoop>(1);

            loops.Add(curveLoop);

            if (!wall.IsStackedWallMember)
            {
                return(ExporterIFCUtils.ComputeAreaOfCurveLoops(loops));
            }
            else
            {
                // Will not get multiple stacked walls with
                // varying thickness due to the nature of rooms.
                // Use ReferenceIntersector if we can identify
                // those missing room faces...open for suggestions.

                SolidHandler solHandler = new SolidHandler();
                Options      optCompRef
                    = doc.Application.Create.NewGeometryOptions();
                if (null != optCompRef)
                {
                    optCompRef.ComputeReferences = true;
                    optCompRef.DetailLevel       = ViewDetailLevel.Medium;
                }

                GeometryElement geomElemHost
                    = wall.get_Geometry(optCompRef)
                      as GeometryElement;

                Solid solidOpening = GeometryCreationUtilities
                                     .CreateExtrusionGeometry(loops,
                                                              cutDir.Negate(), .1);

                Solid solidHost
                    = solHandler.CreateSolidFromBoundingBox(
                          null, geomElemHost.GetBoundingBox(), null);

                // We dont really care about the boundingbox
                // rotation as we only need the intersected solid.

                if (solidHost == null)
                {
                    return(0);
                }

                Solid intersectSolid = BooleanOperationsUtils
                                       .ExecuteBooleanOperation(solidOpening,
                                                                solidHost, BooleanOperationsType.Intersect);

                if (intersectSolid.Faces.Size.Equals(0))
                {
                    solidOpening = GeometryCreationUtilities
                                   .CreateExtrusionGeometry(loops, cutDir, .1);

                    intersectSolid = BooleanOperationsUtils
                                     .ExecuteBooleanOperation(solidOpening,
                                                              solidHost, BooleanOperationsType.Intersect);
                }

                if (DebugHandler.EnableSolidUtilityVolumes)
                {
                    using (Transaction t = new Transaction(doc))
                    {
                        t.Start("Stacked1");
                        ShapeCreator.CreateDirectShape(doc,
                                                       intersectSolid, "stackedOpening");
                        t.Commit();
                    }
                }
                return(solHandler.GetLargestFaceArea(
                           intersectSolid));
            }
        }
예제 #2
0
        public double GetWallAsOpeningArea(
            Element elemOpening,
            Solid solidRoom)
        {
            Document doc = elemOpening.Document;

            Wall wallAsOpening = elemOpening as Wall; // most likely an embedded curtain wall

            Options options = doc.Application.Create.NewGeometryOptions();

            options.ComputeReferences        = true;
            options.IncludeNonVisibleObjects = true;

            List <Element> walls = new List <Element>();

            walls.Add(wallAsOpening);

            // To my recollection this won't
            // pick up an edited wall profile

            List <List <XYZ> > polygons = GetWallProfilePolygons(
                walls, options);

            IList <CurveLoop> solidProfile
                = XYZAsCurveloop(polygons.First());

            Solid solidOpening = GeometryCreationUtilities
                                 .CreateExtrusionGeometry(solidProfile,
                                                          wallAsOpening.Orientation, 1);

            Solid intersectSolid = BooleanOperationsUtils
                                   .ExecuteBooleanOperation(solidOpening,
                                                            solidRoom, BooleanOperationsType.Intersect);

            if (intersectSolid.Faces.Size.Equals(0))
            {
                // Then we are extruding in the wrong direction

                solidOpening = GeometryCreationUtilities
                               .CreateExtrusionGeometry(solidProfile,
                                                        wallAsOpening.Orientation.Negate(), 1);

                intersectSolid = BooleanOperationsUtils
                                 .ExecuteBooleanOperation(solidOpening,
                                                          solidRoom, BooleanOperationsType.Intersect);
            }

            if (DebugHandler.EnableSolidUtilityVolumes)
            {
                using (Transaction t = new Transaction(doc))
                {
                    t.Start("Test1");
                    ShapeCreator.CreateDirectShape(doc,
                                                   intersectSolid, "namesolid");
                    t.Commit();
                }
            }

            double openingArea = GetLargestFaceArea(
                intersectSolid);

            LogCreator.LogEntry(";_______OPENINGAREA;"
                                + elemOpening.Id.ToString() + ";"
                                + elemOpening.Category.Name + ";"
                                + elemOpening.Name + ";"
                                + (openingArea * 0.09290304).ToString());

            return(openingArea);
        }