Exemple #1
0
        /// <summary>
        /// Checks if the wall is legacy curtain wall.
        /// </summary>
        /// <param name="wall">The wall.</param>
        /// <returns>True if it is legacy curtain wall, false otherwise.</returns>
        public static bool IsLegacyCurtainWall(Wall wall)
        {
            try
            {
                CurtainGrid curtainGrid = wall.CurtainGrid;
                if (curtainGrid != null)
                {
                    // The point of this code is to potentially throw an exception. If it does, we have a legacy curtain wall.
                    curtainGrid.GetPanelIds();
                }
                else
                {
                    return(false);
                }
            }
            catch (Autodesk.Revit.Exceptions.InvalidOperationException ex)
            {
                if (ex.Message == "The host object is obsolete.")
                {
                    return(true);
                }
                else
                {
                    throw ex;
                }
            }

            return(false);
        }
Exemple #2
0
        /// <summary>
        /// Returns all of the active curtain panels for a CurtainGrid.
        /// </summary>
        /// <param name="curtainGrid">The CurtainGrid element.</param>
        /// <returns>The element ids of the active curtain panels.</returns>
        /// <remarks>CurtainGrid.GetPanelIds() returns the element ids of the curtain panels that are directly contained in the CurtainGrid.
        /// Some of these panels however, are placeholders for "host" panels.  From a user point of view, the host panels are the real panels,
        /// and should replace these internal panels for export purposes.</remarks>
        public static ICollection <ElementId> GetVisiblePanelsForGrid(CurtainGrid curtainGrid)
        {
            ICollection <ElementId> panelIdsIn = curtainGrid.GetPanelIds();

            if (panelIdsIn == null)
            {
                return(null);
            }

            HashSet <ElementId> visiblePanelIds = new HashSet <ElementId>();

            foreach (ElementId panelId in panelIdsIn)
            {
                Element element = ExporterCacheManager.Document.GetElement(panelId);
                if (element == null)
                {
                    continue;
                }

                ElementId hostPanelId = ElementId.InvalidElementId;
                if (element is Panel)
                {
                    hostPanelId = (element as Panel).FindHostPanel();
                }

                if (hostPanelId != ElementId.InvalidElementId)
                {
                    // If the host panel is itself a curtain wall, then we have to recursively collect its element ids.
                    Element hostPanel = ExporterCacheManager.Document.GetElement(hostPanelId);
                    if (IsCurtainSystem(hostPanel))
                    {
                        CurtainGridSet gridSet = CurtainSystemExporter.GetCurtainGridSet(hostPanel);
                        if (gridSet == null || gridSet.Size == 0)
                        {
                            visiblePanelIds.Add(hostPanelId);
                        }
                        else
                        {
                            ICollection <ElementId> allSubElements = GetSubElements(gridSet);
                            visiblePanelIds.UnionWith(allSubElements);
                        }
                    }
                    else
                    {
                        visiblePanelIds.Add(hostPanelId);
                    }
                }
                else
                {
                    visiblePanelIds.Add(panelId);
                }
            }

            return(visiblePanelIds);
        }
Exemple #3
0
        public static List <Autodesk.Revit.DB.Panel> Panels(this Wall wall, Core.Revit.ConvertSettings convertSettings)
        {
            if (wall == null)
            {
                return(null);
            }

            CurtainGrid curtainGrid = wall.CurtainGrid;

            if (curtainGrid == null)
            {
                return(null);
            }

            IEnumerable <ElementId> elementIds = curtainGrid.GetPanelIds();

            if (elementIds == null || elementIds.Count() == 0)
            {
                return(null);
            }

            List <Autodesk.Revit.DB.Panel> result = new List <Autodesk.Revit.DB.Panel>();

            foreach (ElementId elementId in elementIds)
            {
                Autodesk.Revit.DB.Panel panel = wall.Document.GetElement(elementId) as Autodesk.Revit.DB.Panel;
                if (panel == null)
                {
                    continue;
                }

                ElementId elementId_Host = panel.FindHostPanel();
                if (elementId_Host == null || elementId_Host == ElementId.InvalidElementId)
                {
                    result.Add(panel);
                    continue;
                }

                List <Autodesk.Revit.DB.Panel> panels = Panels(wall.Document.GetElement(elementId_Host) as Wall, convertSettings);
                if (panels != null && panels.Count > 0)
                {
                    result.AddRange(panels);
                }
            }

            return(result);
        }
        /// <summary>
        /// Exports a curtain wall to IFC curtain wall.
        /// </summary>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="hostElement">
        /// The host object element to be exported.
        /// </param>
        /// <param name="productWrapper">
        /// The IFCProductWrapper.
        /// </param>
        public static void ExportWall(ExporterIFC exporterIFC, Wall hostElement, IFCProductWrapper productWrapper)
        {
            // Don't export the Curtain Wall itself, which has no useful geometry; instead export all of the GReps of the
            // mullions and panels.
            CurtainGrid grid = hostElement.CurtainGrid;

            if (grid == null)
            {
                return;
            }

            ICollection <ElementId> allSubElements = grid.GetPanelIds();

            foreach (ElementId subElem in grid.GetMullionIds())
            {
                allSubElements.Add(subElem);
            }
            ExportBase(exporterIFC, allSubElements, hostElement, productWrapper);
        }
        Stream(ArrayList data, CurtainGrid grid)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(CurtainGrid)));

            data.Add(new Snoop.Data.Enumerable("Curtain Cells", grid.GetCurtainCells()));
            data.Add(new Snoop.Data.Enumerable("Mullions", grid.GetMullionIds(), m_activeDoc));
            data.Add(new Snoop.Data.Enumerable("Unlocked mullions", grid.GetUnlockedMullionIds(), m_activeDoc));
            data.Add(new Snoop.Data.Angle("Grid 1 angle", grid.Grid1Angle));
            data.Add(new Snoop.Data.String("Grid 1 justification", grid.Grid1Justification.ToString()));
            data.Add(new Snoop.Data.Double("Grid 1 offset", grid.Grid1Offset));
            data.Add(new Snoop.Data.Angle("Grid 2 angle", grid.Grid2Angle));
            data.Add(new Snoop.Data.String("Grid 2 justification", grid.Grid2Justification.ToString()));
            data.Add(new Snoop.Data.Double("Grid 2 offset", grid.Grid2Offset));
            data.Add(new Snoop.Data.Int("Number of panels", grid.NumPanels));
            data.Add(new Snoop.Data.Enumerable("Panels", grid.GetPanelIds(), m_activeDoc));
            data.Add(new Snoop.Data.Enumerable("Unlocked panels", grid.GetUnlockedPanelIds(), m_activeDoc));
            data.Add(new Snoop.Data.Int("Number of U lines", grid.NumULines));
            data.Add(new Snoop.Data.Enumerable("U grid lines", grid.GetUGridLineIds(), m_activeDoc));
            data.Add(new Snoop.Data.Int("Number of V lines", grid.NumVLines));
            data.Add(new Snoop.Data.Enumerable("V grid lines", grid.GetVGridLineIds(), m_activeDoc));
        }
Exemple #6
0
        public static List <Panel> Panels(this Document document, CurtainGrid curtainGrid)
        {
            if (document == null)
            {
                return(null);
            }

            IEnumerable <ElementId> elementIds = curtainGrid?.GetPanelIds();

            if (elementIds == null || elementIds.Count() == 0)
            {
                return(null);
            }

            List <Panel> result = new List <Panel>();

            foreach (ElementId elementId in elementIds)
            {
                Panel panel = document.GetElement(elementId) as Panel;
                if (panel == null)
                {
                    continue;
                }

                ElementId elementId_Host = panel.FindHostPanel();
                if (elementId_Host == null || elementId_Host == Autodesk.Revit.DB.ElementId.InvalidElementId)
                {
                    result.Add(panel);
                    continue;
                }

                List <Panel> panels = Panels(document.GetElement(elementId_Host) as Wall);
                if (panels != null && panels.Count > 0)
                {
                    result.AddRange(panels);
                }
            }

            return(result);
        }
        /***************************************************/
        /****              Public methods               ****/
        /***************************************************/

        public static List <IOpening> CurtainPanels(this CurtainGrid curtainGrid, Document document, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null)
        {
            if (curtainGrid == null)
            {
                return(null);
            }

            List <IOpening>    result = new List <IOpening>();
            List <Element>     panels = curtainGrid.GetPanelIds().Select(x => document.GetElement(x)).ToList();
            List <CurtainCell> cells  = curtainGrid.GetCurtainCells().ToList();

            if (panels.Count != cells.Count)
            {
                return(null);
            }

            for (int i = 0; i < panels.Count; i++)
            {
                FamilyInstance panel = panels[i] as FamilyInstance;
                if (panel == null || panel.get_BoundingBox(null) == null)
                {
                    continue;
                }

                foreach (PolyCurve pc in cells[i].CurveLoops.FromRevit())
                {
                    if (panel.Category.Id.IntegerValue == (int)Autodesk.Revit.DB.BuiltInCategory.OST_Doors)
                    {
                        result.Add(panel.DoorFromRevit(settings, refObjects));
                    }
                    else
                    {
                        result.Add(panel.WindowFromRevit(settings, refObjects));
                    }
                }
            }

            return(result);
        }
Exemple #8
0
        /// <summary>
        /// Returns all of the active curtain panels for a CurtainGrid.
        /// </summary>
        /// <param name="curtainGrid">The CurtainGrid element.</param>
        /// <returns>The element ids of the active curtain panels.</returns>
        /// <remarks>CurtainGrid.GetPanelIds() returns the element ids of the curtain panels that are directly contained in the CurtainGrid.
        /// Some of these panels however, are placeholders for "host" panels.  From a user point of view, the host panels are the real panels,
        /// and should replace these internal panels for export purposes.</remarks>
        public static HashSet <ElementId> GetVisiblePanelsForGrid(CurtainGrid curtainGrid)
        {
            ICollection <ElementId> panelIdsIn = curtainGrid.GetPanelIds();

            if (panelIdsIn == null)
            {
                return(null);
            }

            HashSet <ElementId> visiblePanelIds = new HashSet <ElementId>();

            foreach (ElementId panelId in panelIdsIn)
            {
                Element element = ExporterCacheManager.Document.GetElement(panelId);
                if (element == null)
                {
                    continue;
                }

                ElementId hostPanelId = ElementId.InvalidElementId;
                if (element is Panel)
                {
                    hostPanelId = (element as Panel).FindHostPanel();
                }

                if (hostPanelId != ElementId.InvalidElementId)
                {
                    visiblePanelIds.Add(hostPanelId);
                }
                else
                {
                    visiblePanelIds.Add(panelId);
                }
            }

            return(visiblePanelIds);
        }
Exemple #9
0
        /// <summary>
        /// Extracts a Dynamo Solid from a Revit Wall object and creates a ParasiteObject
        /// from the extracted geometry
        /// </summary>
        /// <param name="element"></param>
        /// <param name="outPutSolids"></param>
        /// <param name="parasiteObjects"></param>
        /// <param name="OP"></param>
        /// <param name="doc"></param>
        public static void GeometryDataFromWall(Element element, List <DynamoSolid> outPutSolids,
                                                List <ParasiteObject> parasiteObjects, Options OP, Document doc)
        {
            if (element is WallType)
            {
                // Cast Element to WallType
                WallType wallType = element as WallType;

                // Get Geometry Element
                GeometryElement geometryElement = wallType.get_Geometry(OP);

                // Skip if null
                if (geometryElement != null)
                {
                    P_Parameter paramChildLayer = new P_Parameter(P_ParameterType.ChildLayer, wallType.Name, P_StorageType.String);
                    P_Parameter paramLayer      = new P_Parameter(P_ParameterType.Layer, element.Category.Name, P_StorageType.String);

                    DynamoParasiteFactory.CreateParasiteObjectFromGeometryElement(geometryElement,
                                                                                  new P_Parameter[] { paramChildLayer, paramLayer }, outPutSolids, parasiteObjects);
                }
            } // END WALLTYPE CLASS CONDITION


            else if (element is Wall)
            {
                Wall        wall  = element as Wall;
                CurtainGrid cgrid = wall.CurtainGrid;

                //  THIS MEANS WALL IS A GLAZED CURTAIN WALL
                if (cgrid != null)
                {
                    ICollection <ElementId> panelIds = cgrid.GetPanelIds();
                    Element[] panels = panelIds.Select(a => doc.GetElement(a)).ToArray();

                    for (int p = 0; p < panels.Length; p++)
                    {
                        // Ignores Family instances in the Curtain wall. For example doors
                        if (!(panels[p] is Panel panel))
                        {
                            continue;
                        }

                        GeometryElement geometryElement = panel.get_Geometry(OP);

                        if (geometryElement != null)
                        {
                            P_Parameter paramChildLayer = new P_Parameter(P_ParameterType.ChildLayer, panel.Category.Name, P_StorageType.String);
                            P_Parameter paramLayer      = new P_Parameter(P_ParameterType.Layer, element.Category.Name, P_StorageType.String);

                            DynamoParasiteFactory.CreateParasiteObjectFromGeometryElement(geometryElement,
                                                                                          new P_Parameter[] { paramChildLayer, paramLayer }, outPutSolids, parasiteObjects);
                        }
                    }

                    ICollection <ElementId> mullionIds = cgrid.GetMullionIds();
                    Element[] mullions = mullionIds.Select(a => doc.GetElement(a)).ToArray();

                    for (int m = 0; m < mullions.Length; m++)
                    {
                        Mullion mullion = mullions[m] as Mullion;

                        //if (!(mullions[m] is Mullion mullion)) continue;

                        GeometryElement geometryElement = mullion.get_Geometry(OP);

                        if (geometryElement != null)
                        {
                            P_Parameter paramChildLayer = new P_Parameter(P_ParameterType.ChildLayer, mullion.Category.Name, P_StorageType.String);
                            P_Parameter paramLayer      = new P_Parameter(P_ParameterType.Layer, element.Category.Name, P_StorageType.String);

                            DynamoParasiteFactory.CreateParasiteObjectFromGeometryElement(geometryElement,
                                                                                          new P_Parameter[] { paramChildLayer, paramLayer }, outPutSolids, parasiteObjects);
                        }
                    }
                } // End of wall that is a curtain wall

                // THIS MEANS ITS A NORMAL WALL
                else
                {
                    GeometryElement geometryElement = element.get_Geometry(OP);
                    if (geometryElement != null)
                    {
                        P_Parameter paramChildLayer = new P_Parameter(P_ParameterType.ChildLayer, wall.WallType.Name, P_StorageType.String);
                        P_Parameter paramLayer      = new P_Parameter(P_ParameterType.Layer, element.Category.Name, P_StorageType.String);

                        DynamoParasiteFactory.CreateParasiteObjectFromGeometryElement(geometryElement,
                                                                                      new P_Parameter[] { paramChildLayer, paramLayer }, outPutSolids, parasiteObjects);
                    }
                }
            } // END WALL CLASS CONDITION

            else
            {
                throw new ParasiteNotImplementedExceptions("Wall type not implemented yet");
            }
        }
        /// <summary>
        /// Returns all of the curtain panels for a CurtainGrid.
        /// </summary>
        /// <param name="curtainGrid">The CurtainGrid element.</param>
        /// <returns>The element ids of the active curtain panels.</returns>
        public static ICollection <ElementId> GetVisiblePanelsForGrid(CurtainGrid curtainGrid)
        {
            ICollection <ElementId> panelIdsIn = curtainGrid.GetPanelIds();

            return(panelIdsIn);
        }
 /// <summary>
 /// Returns all of the curtain panels for a CurtainGrid.
 /// </summary>
 /// <param name="curtainGrid">The CurtainGrid element.</param>
 /// <returns>The element ids of the active curtain panels.</returns>
 public static ICollection <ElementId> GetVisiblePanelsForGrid(CurtainGrid curtainGrid)
 {
     return(curtainGrid.GetPanelIds());
 }
      Stream(ArrayList data, CurtainGrid grid)
      {
         data.Add(new Snoop.Data.ClassSeparator(typeof(CurtainGrid)));

         data.Add(new Snoop.Data.Enumerable("Curtain Cells", grid.GetCurtainCells()));
         data.Add(new Snoop.Data.Enumerable("Mullions", grid.GetMullionIds(), m_activeDoc));
         data.Add(new Snoop.Data.Enumerable("Unlocked mullions", grid.GetUnlockedMullionIds(), m_activeDoc));
         data.Add(new Snoop.Data.Angle("Grid 1 angle", grid.Grid1Angle));
         data.Add(new Snoop.Data.String("Grid 1 justification", grid.Grid1Justification.ToString()));
         data.Add(new Snoop.Data.Double("Grid 1 offset", grid.Grid1Offset));
         data.Add(new Snoop.Data.Angle("Grid 2 angle", grid.Grid2Angle));
         data.Add(new Snoop.Data.String("Grid 2 justification", grid.Grid2Justification.ToString()));
         data.Add(new Snoop.Data.Double("Grid 2 offset", grid.Grid2Offset));
         data.Add(new Snoop.Data.Int("Number of panels", grid.NumPanels));
         data.Add(new Snoop.Data.Enumerable("Panels", grid.GetPanelIds(), m_activeDoc));
         data.Add(new Snoop.Data.Enumerable("Unlocked panels", grid.GetUnlockedPanelIds(), m_activeDoc));
         data.Add(new Snoop.Data.Int("Number of U lines", grid.NumULines));
         data.Add(new Snoop.Data.Enumerable("U grid lines", grid.GetUGridLineIds(), m_activeDoc));
         data.Add(new Snoop.Data.Int("Number of V lines", grid.NumVLines));
         data.Add(new Snoop.Data.Enumerable("V grid lines", grid.GetVGridLineIds(), m_activeDoc));
      }
        /// <summary>
        /// Returns all of the active curtain panels for a CurtainGrid.
        /// </summary>
        /// <param name="curtainGrid">The CurtainGrid element.</param>
        /// <returns>The element ids of the active curtain panels.</returns>
        /// <remarks>CurtainGrid.GetPanelIds() returns the element ids of the curtain panels that are directly contained in the CurtainGrid.
        /// Some of these panels however, are placeholders for "host" panels.  From a user point of view, the host panels are the real panels,
        /// and should replace these internal panels for export purposes.</remarks>
        public static HashSet<ElementId> GetVisiblePanelsForGrid(CurtainGrid curtainGrid)
        {
            ICollection<ElementId> panelIdsIn = curtainGrid.GetPanelIds();
            if (panelIdsIn == null)
                return null;

            HashSet<ElementId> visiblePanelIds = new HashSet<ElementId>();
            foreach (ElementId panelId in panelIdsIn)
            {
                Element element = ExporterCacheManager.Document.GetElement(panelId);
                if (element == null)
                    continue;

                ElementId hostPanelId = ElementId.InvalidElementId;
                if (element is Panel)
                    hostPanelId = (element as Panel).FindHostPanel();

                if (hostPanelId != ElementId.InvalidElementId)
                    visiblePanelIds.Add(hostPanelId);
                else
                    visiblePanelIds.Add(panelId);
            }

            return visiblePanelIds;
        }
 /// <summary>
 /// Returns all of the curtain panels for a CurtainGrid.
 /// </summary>
 /// <param name="curtainGrid">The CurtainGrid element.</param>
 /// <returns>The element ids of the active curtain panels.</returns>
 public static ICollection<ElementId> GetVisiblePanelsForGrid(CurtainGrid curtainGrid)
 {
     return curtainGrid.GetPanelIds();
 }