Example #1
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))
            {
                string baseDoorPanelName = NamingUtil.GetIFCName(familyInstance);
                for (int panelIndex = 0; (panelIndex < panelNumber - 1); panelIndex++)
                {
                    double? currentPanelWidth = null;
                    if (panelWidthList[panelIndex].HasValue)
                        currentPanelWidth = (double)panelWidthList[panelIndex] / totalPanelWidth;

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

            return doorPanels;
        }
        private static IFCAnyHandle CreateFamilyTypeHandle(ExporterIFC exporterIFC, FamilyTypeInfo typeInfo, IFCDoorWindowInfo doorWindowInfo, 
            IFCAnyHandle bodyRepresentation, IFCAnyHandle planRepresentation,
            Element familyInstance, ElementType familySymbol, ElementType originalFamilySymbol, 
            bool useInstanceGeometry, bool exportParts,
            IFCExportType exportType, string revitObjectType, string ifcEnumType, 
            out HashSet<IFCAnyHandle> propertySets)
        {
            // for many
            propertySets = new HashSet<IFCAnyHandle>();

            IFCFile file = exporterIFC.GetFile();

            IFCAnyHandle repMap2dHnd = null;
            IFCAnyHandle repMap3dHnd = null;

            IList<IFCAnyHandle> repMapList = new List<IFCAnyHandle>();
            {
                IFCAnyHandle origin = null;
                if (bodyRepresentation != null)
                {
                    if (origin == null)
                        origin = ExporterUtil.CreateAxis2Placement3D(file);
                    repMap3dHnd = IFCInstanceExporter.CreateRepresentationMap(file, origin, bodyRepresentation);
                    repMapList.Add(repMap3dHnd);
                }

                if (!IFCAnyHandleUtil.IsNullOrHasNoValue(planRepresentation))
                {
                    if (origin == null)
                        origin = ExporterUtil.CreateAxis2Placement3D(file);
                    repMap2dHnd = IFCInstanceExporter.CreateRepresentationMap(file, origin, planRepresentation);
                    repMapList.Add(repMap2dHnd);
                }
            }

            // We won't allow creating a type if we aren't creating an instance.
            // We won't create the instance if: we are exporting to CV2.0, we have no 2D, 3D, or bounding box geometry, and we aren't exporting parts.
            bool willCreateInstance = !(repMapList.Count == 0 && ExporterCacheManager.ExportOptionsCache.ExportAs2x3CoordinationView2 &&
                !ExporterCacheManager.ExportOptionsCache.ExportBoundingBox && !exportParts);
            if (!willCreateInstance)
                return null;

            IFCAnyHandle typeStyle = null;

            IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();

            // for Door, Window
            bool paramTakesPrecedence = false; // For Revit, this is currently always false.
            bool sizeable = false;

            string guid = useInstanceGeometry ?
                GUIDUtil.CreateSubElementGUID(familyInstance, (int)IFCFamilyInstanceSubElements.InstanceAsType) :
                GUIDUtil.CreateGUID(originalFamilySymbol);
            string symId = NamingUtil.CreateIFCElementId(originalFamilySymbol);

            string gentypeName = NamingUtil.GetNameOverride(familySymbol, revitObjectType);
            string gentypeDescription = NamingUtil.GetDescriptionOverride(familySymbol, null);
            string gentypeApplicableOccurrence = NamingUtil.GetOverrideStringValue(familySymbol, "IfcApplicableOccurrence", null);
            string gentypeTag = NamingUtil.GetTagOverride(familySymbol, symId);
            string gentypeElementType = NamingUtil.GetOverrideStringValue(familySymbol, "IfcElementType", revitObjectType);

            // This covers many generic types.  If we can't find it in the list here, do custom exports.
            typeStyle = FamilyExporterUtil.ExportGenericType(exporterIFC, exportType, ifcEnumType, guid,
               gentypeName, gentypeDescription, gentypeApplicableOccurrence, propertySets, repMapList, gentypeTag, gentypeElementType,
               familyInstance, familySymbol);

            // Cover special cases not covered above.
            if (IFCAnyHandleUtil.IsNullOrHasNoValue(typeStyle))
            {
                string symbolTag = NamingUtil.GetTagOverride(familySymbol, NamingUtil.CreateIFCElementId(familySymbol));
                switch (exportType)
                {
                    case IFCExportType.ExportColumnType:
                        {
                            string columnType = "Column";
                            typeStyle = IFCInstanceExporter.CreateColumnType(file, guid, ownerHistory, gentypeName,
                                gentypeDescription, gentypeApplicableOccurrence, propertySets, repMapList, symbolTag,
                                gentypeElementType, GetColumnType(familyInstance, columnType));
                            break;
                        }
                    case IFCExportType.ExportDoorType:
                        {
                            IFCAnyHandle doorLining = DoorWindowUtil.CreateDoorLiningProperties(exporterIFC, familyInstance);
                            if (!IFCAnyHandleUtil.IsNullOrHasNoValue(doorLining))
                                propertySets.Add(doorLining);

                            IList<IFCAnyHandle> doorPanels = DoorWindowUtil.CreateDoorPanelProperties(exporterIFC, doorWindowInfo,
                               familyInstance);
                            propertySets.UnionWith(doorPanels);

                                string doorStyleGUID = GUIDUtil.CreateSubElementGUID(originalFamilySymbol, (int)IFCDoorSubElements.DoorStyle);
                                typeStyle = IFCInstanceExporter.CreateDoorStyle(file, doorStyleGUID, ownerHistory, gentypeName,
                                   gentypeDescription, gentypeApplicableOccurrence, propertySets, repMapList, symbolTag,
                                DoorWindowUtil.GetDoorStyleOperation(doorWindowInfo.DoorOperationType),
                                DoorWindowUtil.GetDoorStyleConstruction(familyInstance),
                                   paramTakesPrecedence, sizeable);
                            break;
                        }
                    case IFCExportType.ExportSpace:
                        {
                            typeStyle = IFCInstanceExporter.CreateSpaceType(file, guid, ownerHistory, gentypeName,
                               gentypeDescription, gentypeApplicableOccurrence, propertySets, repMapList, symbolTag,
                               gentypeElementType);

                            break;
                        }
                    case IFCExportType.ExportSystemFurnitureElementType:
                        {
                            typeStyle = IFCInstanceExporter.CreateSystemFurnitureElementType(file, guid, ownerHistory, gentypeName,
                               gentypeDescription, gentypeApplicableOccurrence, propertySets, repMapList, symbolTag,
                               gentypeElementType);

                            break;
                        }
                    case IFCExportType.ExportWindowType:
                        {
                            Toolkit.IFCWindowStyleOperation operationType = DoorWindowUtil.GetIFCWindowStyleOperation(originalFamilySymbol);
                            IFCWindowStyleConstruction constructionType = DoorWindowUtil.GetIFCWindowStyleConstruction(familyInstance);

                            IFCAnyHandle windowLining = DoorWindowUtil.CreateWindowLiningProperties(exporterIFC, familyInstance, null);
                            if (!IFCAnyHandleUtil.IsNullOrHasNoValue(windowLining))
                                propertySets.Add(windowLining);

                            IList<IFCAnyHandle> windowPanels =
                               DoorWindowUtil.CreateWindowPanelProperties(exporterIFC, familyInstance, null);
                            propertySets.UnionWith(windowPanels);

                            string windowStyleGUID = GUIDUtil.CreateSubElementGUID(originalFamilySymbol, (int)IFCWindowSubElements.WindowStyle);

                                typeStyle = IFCInstanceExporter.CreateWindowStyle(file, windowStyleGUID, ownerHistory, gentypeName,
                                   gentypeDescription, gentypeApplicableOccurrence, propertySets, repMapList, symbolTag,
                                   constructionType, operationType, paramTakesPrecedence, sizeable);
                            break;
                        }
                    case IFCExportType.ExportBuildingElementProxy:
                    case IFCExportType.ExportBuildingElementProxyType:
                        {
                            typeStyle = IFCInstanceExporter.CreateBuildingElementProxyType(file, guid, ownerHistory, gentypeName,
                                gentypeDescription, gentypeApplicableOccurrence, propertySets, repMapList, symbolTag,
                                gentypeElementType, FamilyExporterUtil.GetBuildingElementProxyType(familyInstance, ifcEnumType));
                            break;
                        }
                }

                if (IFCAnyHandleUtil.IsNullOrHasNoValue(typeStyle))
                {
                    if (!IFCAnyHandleUtil.IsNullOrHasNoValue(repMap2dHnd))
                        typeInfo.Map2DHandle = repMap2dHnd;
                    if (!IFCAnyHandleUtil.IsNullOrHasNoValue(repMap3dHnd))
                        typeInfo.Map3DHandle = repMap3dHnd;
                }
            }

            return typeStyle;
        }
        /// <summary>
        /// Creates door panel properties.
        /// </summary>
        /// <parameter name="exporterIFC">
        /// The ExporterIFC object.
        /// </parameter>
        /// <parameter name="doorWindowInfo">
        /// The IFCDoorWindowInfo object.
        /// </parameter>
        /// <parameter name="familyInstance">
        /// The family instance of a door.
        /// </parameter>
        /// <returns>
        /// The list of handles created.
        /// </returns>
        public static IList<IFCAnyHandle> CreateDoorPanelProperties(ExporterIFC exporterIFC,
           IFCDoorWindowInfo doorWindowInfo, Element familyInstance)
        {
            IFCFile file = exporterIFC.GetFile();
            IFCLabel descriptionOpt = IFCLabel.Create();
            IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();

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

            IList<IFCMeasureValue> panelDepthOptList = new List<IFCMeasureValue>();
            IList<IFCMeasureValue> panelWidthOptList = new List<IFCMeasureValue>();

            IList<string> panelOperationList = new List<string>();
            IList<string> panelPositionList = new List<string>();

            int panelNum = 1;
            const int maxPanels = 64;  // arbitrary large number to prevent infinite loops.
            for (; panelNum < maxPanels; panelNum++)
            {
                string panelDepthCurrString = "PanelDepth" + panelNum.ToString();
                string panelWidthCurrString = "PanelWidth" + panelNum.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.
                string panelPosition = GetIFCDoorPanelPosition("", familyInstance, panelNum);
                if (panelPosition == "")
                {
                    if (panelNum == 1)
                        panelPosition = GetIFCDoorPanelPosition("", familyInstance, -1);
                    if ((panelPosition == "") && (panelNum > 1))
                    {
                        panelPositionList.Add("");
                        break;
                    }
                }

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

                panelPositionList.Add(panelPosition);

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

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

                if (foundDepth && foundWidth)
                {
                    panelDepthOptList.Add(IFCMeasureValue.Create(value1));
                    panelWidthOptList.Add(IFCMeasureValue.Create(value2));
                }
                else
                {
                    panelDepthOptList.Add(IFCMeasureValue.Create());
                    panelWidthOptList.Add(IFCMeasureValue.Create());
                }
            }

            // calculate panelWidths
            double totalPanelWidth = 0.0;
            for (int panelIdx = 0; (panelIdx < panelNum - 1); panelIdx++)
            {
                if (!panelDepthOptList[panelIdx].HasValue || MathUtil.IsAlmostZero(panelDepthOptList[panelIdx].GetValue()) ||
                    !panelWidthOptList[panelIdx].HasValue || MathUtil.IsAlmostZero(panelWidthOptList[panelIdx].GetValue()))
                {
                    totalPanelWidth = 0.0;
                    break;
                }
                totalPanelWidth += panelWidthOptList[panelIdx].GetValue();
            }

            if (!MathUtil.IsAlmostZero(totalPanelWidth))
            {
                for (int panelIdx = 0; (panelIdx < panelNum - 1); panelIdx++)
                {
                    IFCMeasureValue currPanelWidthOpt = IFCMeasureValue.Create(panelWidthOptList[panelIdx].GetValue() / totalPanelWidth);

                    IFCLabel doorPanelGUID = IFCLabel.CreateGUID();
                    IFCLabel doorPanelName = NamingUtil.CreateIFCName(exporterIFC, -1);
                    IFCAnyHandle shapeAspectStyleOpt = IFCAnyHandle.Create();
                    IFCAnyHandle doorPanel = file.CreateDoorPanelProperties(doorPanelGUID, ownerHistory,
                       doorPanelName, descriptionOpt, panelDepthOptList[panelIdx], panelOperationList[panelIdx],
                       currPanelWidthOpt, panelPositionList[panelIdx], shapeAspectStyleOpt);
                    doorPanels.Add(doorPanel);
                }
            }

            return doorPanels;
        }
Example #4
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);
        }