예제 #1
0
        /// <summary>
        /// Checks if element is external.
        /// </summary>
        /// <remarks>
        /// An element is considered external if either:
        ///   <li> A special Yes/No parameter "IsExternal" is applied to it or its type and it's value is set to "yes".</li>
        ///   <li> The element itself has information about being an external element.</li>
        /// All other elements are internal.
        /// </remarks>
        /// <param name="element">The element.</param>
        /// <returns>True if the element is external, false otherwise.</returns>
        public static bool IsElementExternal(Element element)
        {
            if (element == null)
            {
                return(false);
            }

            Document document = element.Document;

            // Look for a parameter "IsExternal", potentially localized.
            {
                ElementId elementId = element.Id;

                bool?maybeIsExternal = null;
                if (!ExporterCacheManager.IsExternalParameterValueCache.TryGetValue(elementId, out maybeIsExternal))
                {
                    int    intIsExternal          = 0;
                    string localExternalParamName = PropertySetEntryUtil.GetLocalizedIsExternal(ExporterCacheManager.LanguageType);
                    if ((localExternalParamName != null) && (ParameterUtil.GetIntValueFromElementOrSymbol(element, localExternalParamName, out intIsExternal) != null))
                    {
                        maybeIsExternal = (intIsExternal != 0);
                    }

                    if (!maybeIsExternal.HasValue && (ExporterCacheManager.LanguageType != LanguageType.English_USA))
                    {
                        string externalParamName = PropertySetEntryUtil.GetLocalizedIsExternal(LanguageType.English_USA);
                        if (ParameterUtil.GetIntValueFromElementOrSymbol(element, externalParamName, out intIsExternal) != null)
                        {
                            maybeIsExternal = (intIsExternal != 0);
                        }
                    }

                    ExporterCacheManager.IsExternalParameterValueCache.Add(new KeyValuePair <ElementId, bool?>(elementId, maybeIsExternal));
                }

                if (maybeIsExternal.HasValue)
                {
                    return(maybeIsExternal.Value);
                }
            }

            // Specific element types that know if they are external or not
            // Categories are used, and not types, to also support in-place families

            // Roofs are always external
            ElementId categoryId = element.Category.Id;

            if (categoryId == new ElementId(BuiltInCategory.OST_Roofs) ||
                categoryId == new ElementId(BuiltInCategory.OST_MassExteriorWall))
            {
                return(true);
            }

            // Mass interior walls are always internal
            if (categoryId == new ElementId(BuiltInCategory.OST_MassInteriorWall))
            {
                return(false);
            }

            // Wall types have the function parameter
            if (element is Wall)
            {
                ElementType wallType = document.GetElement(element.GetTypeId()) as ElementType;
                int         wallFunction;
                if (ParameterUtil.GetIntValueFromElement(wallType, BuiltInParameter.FUNCTION_PARAM, out wallFunction) != null)
                {
                    return(wallFunction != ((int)WallFunction.Interior));
                }
            }

            // Family instances may be hosted on an external element
            if (element is FamilyInstance)
            {
                FamilyInstance familyInstance     = (FamilyInstance)element;
                Element        familyInstanceHost = familyInstance.Host;
                if (familyInstanceHost == null)
                {
                    Reference familyInstanceHostReference = familyInstance.HostFace;
                    if (familyInstanceHostReference != null)
                    {
                        familyInstanceHost = document.GetElement(familyInstanceHostReference);
                    }
                }

                if (familyInstanceHost != null)
                {
                    return(IsElementExternal(familyInstanceHost));
                }
            }

            return(false);
        }
        /// <summary>
        /// Clear all caches contained in this manager.
        /// </summary>
        public static void Clear()
        {
            if (m_AllocatedGeometryObjectCache != null)
            {
                m_AllocatedGeometryObjectCache.DisposeCache();
            }
            ParameterUtil.ClearParameterCache();

            m_AllocatedGeometryObjectCache = null;
            m_AreaSchemeCache                          = null;
            m_AssemblyInstanceCache                    = null;
            m_BeamSystemCache                          = null;
            m_CategoryClassNameCache                   = null;
            m_CategoryTypeCache                        = null;
            m_CeilingSpaceRelCache                     = null;
            m_ClassificationCache                      = null;
            m_ClassificationLocationCache              = null;
            m_ConditionalPropertySetsForTypeCache      = null;
            m_ContainmentCache                         = null;
            m_CurveAnnotationCache                     = null;
            m_DefaultCartesianTransformationOperator3D = null;
            m_DummyHostCache            = null;
            m_ElementToHandleCache      = null;
            m_ElementsInAssembliesCache = null;
            m_ExportOptionsCache        = null;
            m_FabricAreaHandleCache     = null;
            m_GridCache  = null;
            m_GroupCache = null;
            m_GroupElementGeometryCache     = null;
            m_HandleToElementCache          = null;
            m_HostPartsCache                = null;
            m_IsExternalParameterValueCache = null;
            m_LevelInfoCache                = null;
            m_MaterialIdToStyleHandleCache  = null;
            m_MaterialLayerRelationsCache   = null;
            m_MaterialLayerSetCache         = null;
            m_MaterialHandleCache           = null;
            m_MaterialRelationsCache        = null;
            m_MEPCache                    = null;
            m_ParameterCache              = null;
            m_PartExportedCache           = null;
            m_PresentationLayerSetCache   = null;
            m_PresentationStyleCache      = null;
            m_PropertyInfoCache           = null;
            m_PropertyMapCache            = null;
            m_PropertySetsForTypeCache    = null;
            m_RailingCache                = null;
            m_RailingSubElementCache      = null;
            m_SpaceBoundaryCache          = null;
            m_SpaceOccupantInfoCache      = null;
            m_SpatialElementHandleCache   = null;
            m_StairRampContainerInfoCache = null;
            m_SystemsCache                = null;
            m_TrussCache                  = null;
            m_TypeObjectsCache            = null;
            m_TypePropertyInfoCache       = null;
            m_TypeRelationsCache          = null;
            m_ViewScheduleElementCache    = null;
            m_WallConnectionDataCache     = null;
            m_WallTypeCache               = null;
            m_UnitsCache                  = null;
            m_ZoneCache                   = null;
            m_ZoneInfoCache               = null;
        }
예제 #3
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);
        }
예제 #4
0
        /// <summary>
        /// Creates window panel position.
        /// </summary>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="familyInstance">
        /// The family instance of a window.
        /// </param>
        /// <param name="description">
        /// The description.
        /// </param>
        /// <returns>
        /// The handle created.
        /// </returns>
        public static IFCAnyHandle CreateWindowLiningProperties(ExporterIFC exporterIFC,
                                                                Element familyInstance, string description)
        {
            IFCFile      file         = exporterIFC.GetFile();
            IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();

            double?liningDepthOpt         = null;
            double?liningThicknessOpt     = null;
            double?transomThicknessOpt    = null;
            double?mullionThicknessOpt    = null;
            double?firstTransomOffsetOpt  = null;
            double?secondTransomOffsetOpt = null;
            double?firstMullionOffsetOpt  = null;
            double?secondMullionOffsetOpt = null;

            double value1 = 0.0;
            double value2 = 0.0;

            // both of these must be defined (or not defined)
            if (ParameterUtil.GetDoubleValueFromElementOrSymbol(familyInstance, "LiningDepth", out value1) &&
                ParameterUtil.GetDoubleValueFromElementOrSymbol(familyInstance, "LiningThickness", out value2))
            {
                liningDepthOpt     = value1;
                liningThicknessOpt = value2;
            }

            if (ParameterUtil.GetDoubleValueFromElementOrSymbol(familyInstance, "TransomThickness", out value1))
            {
                transomThicknessOpt = value1;
            }

            if (ParameterUtil.GetDoubleValueFromElementOrSymbol(familyInstance, "FirstTransomOffset", out value1))
            {
                firstTransomOffsetOpt = value1;
            }

            if (ParameterUtil.GetDoubleValueFromElementOrSymbol(familyInstance, "SecondTransomOffset", out value1))
            {
                secondTransomOffsetOpt = value1;
            }

            if (ParameterUtil.GetDoubleValueFromElementOrSymbol(familyInstance, "MullionThickness", out value1))
            {
                mullionThicknessOpt = value1;
            }

            if (ParameterUtil.GetDoubleValueFromElementOrSymbol(familyInstance, "FirstMullionOffset", out value1))
            {
                firstMullionOffsetOpt = value1;
            }

            if (ParameterUtil.GetDoubleValueFromElementOrSymbol(familyInstance, "SecondMullionOffset", out value1))
            {
                secondMullionOffsetOpt = value1;
            }

            string windowLiningGUID = ExporterIFCUtils.CreateGUID();
            string windowLiningName = exporterIFC.GetName();

            return(IFCInstanceExporter.CreateWindowLiningProperties(file, windowLiningGUID, ownerHistory,
                                                                    windowLiningName, description, liningDepthOpt, liningThicknessOpt, transomThicknessOpt, mullionThicknessOpt,
                                                                    firstTransomOffsetOpt, secondTransomOffsetOpt, firstMullionOffsetOpt, secondMullionOffsetOpt, null));
        }
예제 #5
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);
        }
예제 #6
0
        /// <summary>
        /// Creates door lining properties.
        /// </summary>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="familyInstance">
        /// The family instance of a door.
        /// </param>
        /// <returns>
        /// The handle created.
        /// </returns>
        public static IFCAnyHandle CreateDoorLiningProperties(ExporterIFC exporterIFC, Element familyInstance)
        {
            IFCFile      file         = exporterIFC.GetFile();
            IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();

            double?liningDepthOpt        = null;
            double?liningThicknessOpt    = null;
            double?thresholdDepthOpt     = null;
            double?thresholdThicknessOpt = null;
            double?transomThicknessOpt   = null;
            double?transomOffsetOpt      = null;
            double?liningOffsetOpt       = null;
            double?thresholdOffsetOpt    = null;
            double?casingThicknessOpt    = null;
            double?casingDepthOpt        = null;

            double value1, value2;

            // both of these must be defined, or not defined - if only one is defined, we ignore the values.
            if (ParameterUtil.GetPositiveDoubleValueFromElementOrSymbol(familyInstance, "LiningDepth", out value1))
            {
                if (ParameterUtil.GetPositiveDoubleValueFromElementOrSymbol(familyInstance, "LiningThickness", out value2))
                {
                    liningDepthOpt     = value1;
                    liningThicknessOpt = value2;
                }
            }

            if (ParameterUtil.GetDoubleValueFromElementOrSymbol(familyInstance, "LiningOffset", out value1))
            {
                liningOffsetOpt = value1;
            }

            // both of these must be defined, or not defined - if only one is defined, we ignore the values.
            if (ParameterUtil.GetPositiveDoubleValueFromElementOrSymbol(familyInstance, "ThresholdDepth", out value1))
            {
                if (ParameterUtil.GetPositiveDoubleValueFromElementOrSymbol(familyInstance, "ThresholdThickness", out value2))
                {
                    thresholdDepthOpt     = value1;
                    thresholdThicknessOpt = value2;
                }
            }

            if (ParameterUtil.GetDoubleValueFromElementOrSymbol(familyInstance, "ThreshholdOffset", out value1))
            {
                liningOffsetOpt = value1;
            }

            // both of these must be defined, or not defined - if only one is defined, we ignore the values.
            if (ParameterUtil.GetDoubleValueFromElementOrSymbol(familyInstance, "TransomOffset", out value1))
            {
                if (ParameterUtil.GetPositiveDoubleValueFromElementOrSymbol(familyInstance, "TransomThickness", out value2))
                {
                    transomOffsetOpt    = value1;
                    transomThicknessOpt = value2;
                }
            }

            // both of these must be defined, or not defined - if only one is defined, we ignore the values.
            if (ParameterUtil.GetPositiveDoubleValueFromElementOrSymbol(familyInstance, "CasingDepth", out value1))
            {
                if (ParameterUtil.GetPositiveDoubleValueFromElementOrSymbol(familyInstance, "CasingThickness", out value2))
                {
                    casingDepthOpt     = value1;
                    casingThicknessOpt = value2;
                }
            }

            string doorLiningGUID = ExporterIFCUtils.CreateSubElementGUID(familyInstance, (int)IFCDoorSubElements.DoorLining);
            string doorLiningName = exporterIFC.GetName();

            return(IFCInstanceExporter.CreateDoorLiningProperties(file, doorLiningGUID, ownerHistory,
                                                                  doorLiningName, null, liningDepthOpt, liningThicknessOpt, thresholdDepthOpt, thresholdThicknessOpt,
                                                                  transomThicknessOpt, transomOffsetOpt, liningOffsetOpt, thresholdOffsetOpt, casingThicknessOpt,
                                                                  casingDepthOpt, null));
        }
예제 #7
0
        /// <summary>
        /// Creates door panel properties.
        /// </summary>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="doorWindowInfo">
        /// The IFCDoorWindowInfo object.
        /// </param>
        /// <param name="familyInstance">
        /// The family instance of a door.
        /// </param>
        /// <returns>
        /// The list of handles created.
        /// </returns>
        public static IList <IFCAnyHandle> CreateDoorPanelProperties(ExporterIFC exporterIFC,
                                                                     IFCDoorWindowInfo doorWindowInfo, Element familyInstance)
        {
            IFCFile      file         = exporterIFC.GetFile();
            IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();

            IList <IFCAnyHandle> doorPanels = new List <IFCAnyHandle>();

            IList <double?> panelDepthList = new List <double?>();
            IList <double?> panelWidthList = new List <double?>();

            IList <IFCDoorPanelOperation> panelOperationList = new List <IFCDoorPanelOperation>();
            IList <IFCDoorPanelPosition>  panelPositionList  = new List <IFCDoorPanelPosition>();

            int       panelNumber = 1;
            const int maxPanels   = 64; // arbitrary large number to prevent infinite loops.

            for (; panelNumber < maxPanels; panelNumber++)
            {
                string panelDepthCurrString = "PanelDepth" + panelNumber.ToString();
                string panelWidthCurrString = "PanelWidth" + panelNumber.ToString();

                // We will always have at least one panel definition as long as the panelOperation is not
                // NotDefined.

                panelOperationList.Add(GetPanelOperationFromDoorStyleOperation(doorWindowInfo.DoorOperationType));

                // If the panel operation is defined we'll allow no panel position for the 1st panel.
                IFCDoorPanelPosition?panelPosition = GetIFCDoorPanelPosition("", familyInstance, panelNumber);
                if (panelPosition == null)
                {
                    if (panelNumber == 1)
                    {
                        panelPosition = GetIFCDoorPanelPosition("", familyInstance, -1);
                    }
                    if ((panelPosition == null) && (panelNumber > 1))
                    {
                        panelPositionList.Add(IFCDoorPanelPosition.NotDefined);
                        break;
                    }
                }

                if (doorWindowInfo.IsFlippedInX ^ doorWindowInfo.IsFlippedInY)
                {
                    panelPosition = ReverseDoorPanelPosition(panelPosition);
                }

                panelPositionList.Add(panelPosition != null ? (IFCDoorPanelPosition)panelPosition : IFCDoorPanelPosition.NotDefined);

                double value1 = 0.0, value2 = 0.0;
                bool   foundDepth = ParameterUtil.GetPositiveDoubleValueFromElementOrSymbol(familyInstance, panelDepthCurrString, out value1);
                if (!foundDepth && (panelNumber == 1))
                {
                    foundDepth = ParameterUtil.GetPositiveDoubleValueFromElementOrSymbol(familyInstance, "PanelDepth", out value1);
                }

                bool foundWidth = ParameterUtil.GetPositiveDoubleValueFromElementOrSymbol(familyInstance, panelWidthCurrString, out value2);
                if (!foundWidth && (panelNumber == 1))
                {
                    foundWidth = ParameterUtil.GetPositiveDoubleValueFromElementOrSymbol(familyInstance, "PanelWidth", out value2);
                }

                if (foundDepth && foundWidth)
                {
                    panelDepthList.Add(value1);
                    panelWidthList.Add(value2);
                }
                else
                {
                    panelDepthList.Add(null);
                    panelWidthList.Add(null);
                }
            }

            // calculate panelWidths
            double totalPanelWidth = 0.0;

            for (int panelIndex = 0; (panelIndex < panelNumber - 1); panelIndex++)
            {
                if (panelDepthList[panelIndex] == null || MathUtil.IsAlmostZero((double)panelDepthList[panelIndex]) ||
                    panelWidthList[panelIndex] == null || MathUtil.IsAlmostZero((double)panelWidthList[panelIndex]))
                {
                    totalPanelWidth = 0.0;
                    break;
                }
                totalPanelWidth += (double)panelWidthList[panelIndex];
            }

            if (!MathUtil.IsAlmostZero(totalPanelWidth))
            {
                for (int panelIndex = 0; (panelIndex < panelNumber - 1); panelIndex++)
                {
                    double?currentPanelWidth = null;
                    if (panelWidthList[panelIndex].HasValue)
                    {
                        currentPanelWidth = (double)panelWidthList[panelIndex] / totalPanelWidth;
                    }

                    string       doorPanelGUID = ExporterIFCUtils.CreateGUID();
                    string       doorPanelName = exporterIFC.GetName();
                    IFCAnyHandle doorPanel     = IFCInstanceExporter.CreateDoorPanelProperties(file, doorPanelGUID, ownerHistory,
                                                                                               doorPanelName, null, panelDepthList[panelIndex], panelOperationList[panelIndex],
                                                                                               currentPanelWidth, panelPositionList[panelIndex], null);
                    doorPanels.Add(doorPanel);
                }
            }

            return(doorPanels);
        }