Beispiel #1
0
        /// <summary>
        /// Creates a shape representation and register it to shape representation layer.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="categoryId">The category id.</param>
        /// <param name="contextOfItems">The context for which the different subtypes of representation are valid.</param>
        /// <param name="identifier">The identifier for the representation.</param>
        /// <param name="representationType">The type handle for the representation.</param>
        /// <param name="items">Collection of geometric representation items that are defined for this representation.</param>
        /// <returns>The handle.</returns>
        public static IFCAnyHandle CreateShapeRepresentation(ExporterIFC exporterIFC, Element element, ElementId categoryId, IFCAnyHandle contextOfItems,
                                                             string identifier, string representationType, ICollection <IFCAnyHandle> items)
        {
            IFCAnyHandle newShapeRepresentation = CreateBaseShapeRepresentation(exporterIFC, contextOfItems, identifier, representationType, items);

            if (IFCAnyHandleUtil.IsNullOrHasNoValue(newShapeRepresentation))
            {
                return(newShapeRepresentation);
            }

            string ifcCADLayer = null;

            if ((ParameterUtil.GetStringValueFromElementOrSymbol(element, "IFCCadLayer", out ifcCADLayer) == null) || string.IsNullOrWhiteSpace(ifcCADLayer))
            {
                ifcCADLayer = ExporterStateManager.GetCurrentCADLayerOverride();
            }

            // We are using the DWG export layer table to correctly map category to DWG layer for the
            // IfcPresentationLayerAsssignment, if it is not overridden.
            if (!string.IsNullOrWhiteSpace(ifcCADLayer))
            {
                ExporterCacheManager.PresentationLayerSetCache.AddRepresentationToLayer(ifcCADLayer, newShapeRepresentation);
            }
            else
            {
                exporterIFC.RegisterShapeForPresentationLayer(element, categoryId, newShapeRepresentation);
            }

            return(newShapeRepresentation);
        }
Beispiel #2
0
        /// <summary>
        /// Gets IFCDoorStyleConstruction from construction type name.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns>The IFCDoorStyleConstruction.</returns>
        public static IFCDoorStyleConstruction GetDoorStyleConstruction(Element element)
        {
            string value = null;

            if (ParameterUtil.GetStringValueFromElementOrSymbol(element, "Construction", out value) == null)
            {
                ParameterUtil.GetStringValueFromElementOrSymbol(element, BuiltInParameter.DOOR_CONSTRUCTION_TYPE, false, out value);
            }

            if (String.IsNullOrEmpty(value))
            {
                return(IFCDoorStyleConstruction.NotDefined);
            }

            string newValue = NamingUtil.RemoveSpacesAndUnderscores(value);

            if (String.Compare(newValue, "USERDEFINED", true) == 0)
            {
                return(IFCDoorStyleConstruction.UserDefined);
            }
            if (String.Compare(newValue, "ALUMINIUM", true) == 0)
            {
                return(IFCDoorStyleConstruction.Aluminium);
            }
            if (String.Compare(newValue, "HIGH_GRADE_STEEL", true) == 0)
            {
                return(IFCDoorStyleConstruction.High_Grade_Steel);
            }
            if (String.Compare(newValue, "STEEL", true) == 0)
            {
                return(IFCDoorStyleConstruction.Steel);
            }
            if (String.Compare(newValue, "WOOD", true) == 0)
            {
                return(IFCDoorStyleConstruction.Wood);
            }
            if (String.Compare(newValue, "ALUMINIUM_WOOD", true) == 0)
            {
                return(IFCDoorStyleConstruction.Aluminium_Wood);
            }
            if (String.Compare(newValue, "ALUMINIUM_PLASTIC", true) == 0)
            {
                return(IFCDoorStyleConstruction.Aluminium_Plastic);
            }
            if (String.Compare(newValue, "PLASTIC", true) == 0)
            {
                return(IFCDoorStyleConstruction.Plastic);
            }

            return(IFCDoorStyleConstruction.UserDefined);
        }
Beispiel #3
0
        /// <summary>
        /// Gets window style construction.
        /// </summary>
        /// <param name="element">
        /// The window element.
        /// </param>
        /// <param name="initialValue">
        /// The initial value.
        /// </param>
        /// <returns>
        /// The string represents the window style construction.
        /// </returns>
        public static IFCWindowStyleConstruction GetIFCWindowStyleConstruction(Element element, string initialValue)
        {
            string value;

            if (!ParameterUtil.GetStringValueFromElementOrSymbol(element, "Construction", out value))
            {
                value = initialValue;
            }

            if (value == "")
            {
                return(IFCWindowStyleConstruction.NotDefined);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "Aluminum"))
            {
                return(IFCWindowStyleConstruction.Aluminium);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "HighGradeSteel"))
            {
                return(IFCWindowStyleConstruction.High_Grade_Steel);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "Steel"))
            {
                return(IFCWindowStyleConstruction.Steel);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "Wood"))
            {
                return(IFCWindowStyleConstruction.Wood);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "AluminumWood"))
            {
                return(IFCWindowStyleConstruction.Aluminium_Wood);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "Plastic"))
            {
                return(IFCWindowStyleConstruction.Plastic);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "OtherConstruction"))
            {
                return(IFCWindowStyleConstruction.Other_Construction);
            }

            return(IFCWindowStyleConstruction.NotDefined);
        }
Beispiel #4
0
        /// <summary>
        /// Gets door panel position.
        /// </summary>
        /// <param name="typeName">
        /// The type name of the door.
        /// </param>
        /// <param name="element">
        /// The door element.
        /// </param>
        /// <param name="number">
        /// The number of panel position.
        /// </param>
        /// <returns>
        /// The string represents the door panel position.
        /// </returns>
        public static IFCDoorPanelPosition?GetIFCDoorPanelPosition(string typeName, Element element, int number)
        {
            string currPanelName;

            if (number == -1)
            {
                currPanelName = "PanelPosition";
            }
            else
            {
                currPanelName = "PanelPosition" + number.ToString();
            }

            string value = "";

            if (!ParameterUtil.GetStringValueFromElementOrSymbol(element, currPanelName, out value))
            {
                value = typeName;
            }

            if (value == "")
            {
                return(null);
            }
            else if (String.Compare(value, "left", true) == 0)
            {
                return(IFCDoorPanelPosition.Left);
            }
            else if (String.Compare(value, "middle", true) == 0)
            {
                return(IFCDoorPanelPosition.Middle);
            }
            else if (String.Compare(value, "right", true) == 0)
            {
                return(IFCDoorPanelPosition.Right);
            }
            else
            {
                return(IFCDoorPanelPosition.NotDefined);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Gets window style construction.
        /// </summary>
        /// <param name="element">The window element.</param>
        /// <returns>The string represents the window style construction.</returns>
        public static IFCWindowStyleConstruction GetIFCWindowStyleConstruction(Element element)
        {
            string value;

            if (ParameterUtil.GetStringValueFromElementOrSymbol(element, "Construction", out value) == null)
            {
                ParameterUtil.GetStringValueFromElementOrSymbol(element, BuiltInParameter.WINDOW_CONSTRUCTION_TYPE, false, out value);
            }

            if (String.IsNullOrWhiteSpace(value))
            {
                return(IFCWindowStyleConstruction.NotDefined);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "Aluminum"))
            {
                return(IFCWindowStyleConstruction.Aluminium);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "HighGradeSteel"))
            {
                return(IFCWindowStyleConstruction.High_Grade_Steel);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "Steel"))
            {
                return(IFCWindowStyleConstruction.Steel);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "Wood"))
            {
                return(IFCWindowStyleConstruction.Wood);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "AluminumWood"))
            {
                return(IFCWindowStyleConstruction.Aluminium_Wood);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "Plastic"))
            {
                return(IFCWindowStyleConstruction.Plastic);
            }

            //else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "OtherConstruction"))
            return(IFCWindowStyleConstruction.Other_Construction);
        }
Beispiel #6
0
        /// <summary>
        /// Gets window panel position.
        /// </summary>
        /// <param name="initialValue">
        /// The initial value.
        /// </param>
        /// <param name="element">
        /// The window element.
        /// </param>
        /// <param name="number">
        /// The number of panel position.
        /// </param>
        /// <returns>
        /// The string represents the window panel position.
        /// </returns>
        public static IFCWindowPanelPosition GetIFCWindowPanelPosition(string initialValue, Element element, int number)
        {
            string currPanelName = "PanelPosition" + number.ToString();

            string value;

            if (!ParameterUtil.GetStringValueFromElementOrSymbol(element, currPanelName, out value))
            {
                value = initialValue;
            }

            if (value == "")
            {
                return(IFCWindowPanelPosition.NotDefined);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "Left"))
            {
                return(IFCWindowPanelPosition.Left);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "Middle"))
            {
                return(IFCWindowPanelPosition.Middle);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "Right"))
            {
                return(IFCWindowPanelPosition.Right);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "Bottom"))
            {
                return(IFCWindowPanelPosition.Bottom);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "Top"))
            {
                return(IFCWindowPanelPosition.Top);
            }

            return(IFCWindowPanelPosition.NotDefined);
        }
Beispiel #7
0
        /// <summary>
        /// Gets export type for an element.
        /// </summary>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="element">
        /// The element.
        /// </param>
        /// <param name="enumTypeValue">
        /// The output string value represents the enum type.
        /// </param>
        /// <returns>
        /// The IFCExportType.
        /// </returns>
        public static IFCExportType GetExportType(ExporterIFC exporterIFC, Element element,
                                                  out string enumTypeValue)
        {
            enumTypeValue = "";
            IFCExportType exportType = IFCExportType.DontExport;

            // Get potential override value first.
            {
                string symbolClassName;

                string exportAsEntity = "IFCExportAs";
                string exportAsType   = "IFCExportType";

                ParameterUtil.GetStringValueFromElementOrSymbol(element, exportAsEntity, out symbolClassName);
                ParameterUtil.GetStringValueFromElementOrSymbol(element, exportAsType, out enumTypeValue);

                if (!String.IsNullOrEmpty(symbolClassName))
                {
                    exportType = ElementFilteringUtil.GetExportTypeFromClassName(symbolClassName);
                    if (exportType != IFCExportType.DontExport)
                    {
                        return(exportType);
                    }
                }
            }

            Category category = element.Category;

            if (category == null)
            {
                return(IFCExportType.DontExport);
            }

            ElementId categoryId = category.Id;

            string ifcClassName = ExporterIFCUtils.GetIFCClassName(element, exporterIFC);

            if (ifcClassName != "")
            {
                enumTypeValue = ExporterIFCUtils.GetIFCType(element, exporterIFC);
                // if using name, override category id if match is found.
                if (!ifcClassName.Equals("Default", StringComparison.OrdinalIgnoreCase))
                {
                    exportType = ElementFilteringUtil.GetExportTypeFromClassName(ifcClassName);
                }
            }

            // if not set, fall back on category id.
            if (exportType == IFCExportType.DontExport)
            {
                //bool exportSeparately = true;
                exportType = ElementFilteringUtil.GetExportTypeFromCategoryId(categoryId, out enumTypeValue /*, out bool exportSeparately*/);
            }

            // if not set, fall back on symbol functions.
            // allow override of IfcBuildingElementProxy.
            if ((exportType == IFCExportType.DontExport) || (exportType == IFCExportType.ExportBuildingElementProxy))
            {
                // TODO: add isColumn.
                //if (familySymbol.IsColumn())
                //exportType = IFCExportType.ExportColumnType;
                //else
                FamilyInstance familyInstance = element as FamilyInstance;
                if (familyInstance != null)
                {
                    switch (familyInstance.StructuralType)
                    {
                    case Autodesk.Revit.DB.Structure.StructuralType.Beam:
                        exportType = IFCExportType.ExportBeam;
                        break;

                    case Autodesk.Revit.DB.Structure.StructuralType.Footing:
                        exportType = IFCExportType.ExportFooting;
                        break;
                    }
                }
            }

            return(exportType);
        }
Beispiel #8
0
        /// <summary>
        /// Gets window panel operation.
        /// </summary>
        /// <param name="initialValue">
        /// The initial value.
        /// </param>
        /// <param name="element">
        /// The window element.
        /// </param>
        /// <param name="number">
        /// The number of panel operation.
        /// </param>
        /// <returns>
        /// The string represents the window panel operation.
        /// </returns>
        public static IFCWindowPanelOperation GetIFCWindowPanelOperation(string initialValue, Element element, int number)
        {
            string currPanelName = "PanelOperation" + number.ToString();

            string value;

            if (!ParameterUtil.GetStringValueFromElementOrSymbol(element, currPanelName, out value))
            {
                value = initialValue;
            }

            if (value == "")
            {
                return(IFCWindowPanelOperation.NotDefined);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "SideHungRightHand"))
            {
                return(IFCWindowPanelOperation.SideHungRightHand);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "SideHungLeftHand"))
            {
                return(IFCWindowPanelOperation.SideHungLeftHand);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "TiltAndTurnRightHand"))
            {
                return(IFCWindowPanelOperation.TiltAndTurnRightHand);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "TiltAndTurnLeftHand"))
            {
                return(IFCWindowPanelOperation.TiltAndTurnLeftHand);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "TopHung"))
            {
                return(IFCWindowPanelOperation.TopHung);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "BottomHung"))
            {
                return(IFCWindowPanelOperation.BottomHung);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "PivotHorizontal"))
            {
                return(IFCWindowPanelOperation.PivotHorizontal);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "PivotVertical"))
            {
                return(IFCWindowPanelOperation.PivotVertical);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "SlidingHorizontal"))
            {
                return(IFCWindowPanelOperation.SlidingHorizontal);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "SlidingVertical"))
            {
                return(IFCWindowPanelOperation.SlidingVertical);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "RemovableCasement"))
            {
                return(IFCWindowPanelOperation.RemovableCasement);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "FixedCasement"))
            {
                return(IFCWindowPanelOperation.FixedCasement);
            }
            else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(value, "OtherOperation"))
            {
                return(IFCWindowPanelOperation.OtherOperation);
            }

            return(IFCWindowPanelOperation.NotDefined);
        }