Esempio n. 1
0
        /// <summary>
        /// Creates window 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 window.
        /// </param>
        /// <param name="description">
        /// The description.
        /// </param>
        /// <returns>
        /// The list of handles created.
        /// </returns>
        public static IList <IFCAnyHandle> CreateWindowPanelProperties(ExporterIFC exporterIFC,
                                                                       Element familyInstance, string description)
        {
            IList <IFCAnyHandle> panels = new List <IFCAnyHandle>();
            IFCFile      file           = exporterIFC.GetFile();
            IFCAnyHandle ownerHistory   = exporterIFC.GetOwnerHistoryHandle();

            double lengthScale = exporterIFC.LinearScale;

            const int maxPanels = 1000;  // arbitrary large number to prevent infinite loops.

            for (int panelNumber = 1; panelNumber < maxPanels; panelNumber++)
            {
                string frameDepthCurrString     = "FrameDepth" + panelNumber.ToString();
                string frameThicknessCurrString = "FrameThickness" + panelNumber.ToString();

                IFCWindowPanelOperation panelOperation = GetIFCWindowPanelOperation("", familyInstance, panelNumber);
                IFCWindowPanelPosition  panelPosition  = GetIFCWindowPanelPosition("", familyInstance, panelNumber);
                if (panelOperation == IFCWindowPanelOperation.NotDefined && panelPosition == IFCWindowPanelPosition.NotDefined)
                {
                    break;
                }

                double?frameDepth     = null;
                double?frameThickness = null;

                double value1, value2;
                if (((ParameterUtil.GetDoubleValueFromElementOrSymbol(familyInstance, frameDepthCurrString, out value1) != null) ||
                     ((panelNumber == 1) && (ParameterUtil.GetDoubleValueFromElementOrSymbol(familyInstance, "FrameDepth", out value1) != null))) &&
                    ((ParameterUtil.GetDoubleValueFromElementOrSymbol(familyInstance, frameThicknessCurrString, out value2) != null) ||
                     ((panelNumber == 1) && (ParameterUtil.GetDoubleValueFromElementOrSymbol(familyInstance, "FrameThickness", out value2) != null))))
                {
                    frameDepth     = value1 * lengthScale;
                    frameThickness = value2 * lengthScale;
                }

                string panelGUID = GUIDUtil.CreateGUID();
                string panelName = NamingUtil.GetIFCNamePlusIndex(familyInstance, panelNumber);
                panels.Add(IFCInstanceExporter.CreateWindowPanelProperties(file, panelGUID, ownerHistory,
                                                                           panelName, description, panelOperation, panelPosition, frameDepth, frameThickness, null));
            }
            return(panels);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates openings if there is necessary.
        /// </summary>
        /// <param name="elementHandle">The element handle to create openings.</param>
        /// <param name="element">The element to create openings.</param>
        /// <param name="info">The extrusion data.</param>
        /// <param name="extraParams">The extrusion creation data.</param>
        /// <param name="offsetTransform">The offset transform from ExportBody, or the identity transform.</param>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="originalPlacement">The original placement handle.</param>
        /// <param name="setter">The PlacementSetter.</param>
        /// <param name="wrapper">The ProductWrapper.</param>
        private static void CreateOpeningsIfNecessaryBase(IFCAnyHandle elementHandle, Element element, IList <IFCExtrusionData> info,
                                                          IFCExtrusionCreationData extraParams, Transform offsetTransform, ExporterIFC exporterIFC,
                                                          IFCAnyHandle originalPlacement, IFCPlacementSetter setter, ProductWrapper wrapper)
        {
            if (IFCAnyHandleUtil.IsNullOrHasNoValue(elementHandle))
            {
                return;
            }

            int sz = info.Count;

            if (sz == 0)
            {
                return;
            }

            using (IFCTransformSetter transformSetter = IFCTransformSetter.Create())
            {
                if (offsetTransform != null)
                {
                    transformSetter.Initialize(exporterIFC, offsetTransform.Inverse);
                }

                IFCFile   file       = exporterIFC.GetFile();
                ElementId categoryId = CategoryUtil.GetSafeCategoryId(element);
                Document  document   = element.Document;

                string openingObjectType = "Opening";

                int openingNumber = 1;
                for (int curr = info.Count - 1; curr >= 0; curr--)
                {
                    IFCAnyHandle extrusionHandle = ExtrusionExporter.CreateExtrudedSolidFromExtrusionData(exporterIFC, element, info[curr]);
                    if (IFCAnyHandleUtil.IsNullOrHasNoValue(extrusionHandle))
                    {
                        continue;
                    }

                    IFCAnyHandle styledItemHnd = BodyExporter.CreateSurfaceStyleForRepItem(exporterIFC, document,
                                                                                           extrusionHandle, ElementId.InvalidElementId);

                    HashSet <IFCAnyHandle> bodyItems = new HashSet <IFCAnyHandle>();
                    bodyItems.Add(extrusionHandle);

                    IFCAnyHandle         contextOfItems  = exporterIFC.Get3DContextHandle("Body");
                    IFCAnyHandle         bodyRep         = RepresentationUtil.CreateSweptSolidRep(exporterIFC, element, categoryId, contextOfItems, bodyItems, null);
                    IList <IFCAnyHandle> representations = new List <IFCAnyHandle>();
                    representations.Add(bodyRep);

                    IFCAnyHandle openingRep = IFCInstanceExporter.CreateProductDefinitionShape(file, null, null, representations);

                    IFCAnyHandle openingPlacement = ExporterUtil.CopyLocalPlacement(file, originalPlacement);
                    string       guid             = GUIDUtil.CreateGUID();
                    IFCAnyHandle ownerHistory     = exporterIFC.GetOwnerHistoryHandle();
                    string       openingName      = NamingUtil.GetIFCNamePlusIndex(element, openingNumber++);
                    string       elementId        = NamingUtil.CreateIFCElementId(element);
                    IFCAnyHandle openingElement   = IFCInstanceExporter.CreateOpeningElement(file, guid, ownerHistory,
                                                                                             openingName, null, openingObjectType, openingPlacement, openingRep, elementId);
                    wrapper.AddElement(null, openingElement, setter, extraParams, true);
                    if (ExporterCacheManager.ExportOptionsCache.ExportBaseQuantities && (extraParams != null))
                    {
                        ExporterIFCUtils.CreateOpeningQuantities(exporterIFC, openingElement, extraParams);
                    }

                    string voidGuid = GUIDUtil.CreateGUID();
                    IFCInstanceExporter.CreateRelVoidsElement(file, voidGuid, ownerHistory, null, null, elementHandle, openingElement);
                }
            }
        }
Esempio n. 3
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) != null);
                if (!foundDepth && (panelNumber == 1))
                {
                    foundDepth = (ParameterUtil.GetPositiveDoubleValueFromElementOrSymbol(familyInstance, "PanelDepth", out value1) != null);
                }

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

                if (foundDepth && foundWidth)
                {
                    double lengthScale = exporterIFC.LinearScale;

                    panelDepthList.Add(value1 * lengthScale);
                    // Make sure value is in [0,1] range.
                    if (value2 < 0.0)
                    {
                        value2 = 0.0;
                    }
                    else if (value2 > 1.0)
                    {
                        value2 = 1.0;
                    }
                    panelWidthList.Add(value2);
                }
                else
                {
                    panelDepthList.Add(null);
                    panelWidthList.Add(null);
                }
            }

            string baseDoorPanelName = NamingUtil.GetIFCName(familyInstance);

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

                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);
        }
Esempio n. 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;

            double scale = exporterIFC.LinearScale;

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

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

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

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

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

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

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

            string windowLiningGUID = GUIDUtil.CreateGUID();
            string windowLiningName = NamingUtil.GetIFCName(familyInstance);

            return(IFCInstanceExporter.CreateWindowLiningProperties(file, windowLiningGUID, ownerHistory,
                                                                    windowLiningName, description, liningDepthOpt, liningThicknessOpt, transomThicknessOpt, mullionThicknessOpt,
                                                                    firstTransomOffsetOpt, secondTransomOffsetOpt, firstMullionOffsetOpt, secondMullionOffsetOpt, null));
        }
Esempio n. 5
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;

            double scale = exporterIFC.LinearScale;

            // 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) != null) &&
                (ParameterUtil.GetPositiveDoubleValueFromElementOrSymbol(familyInstance, "LiningThickness", out value2) != null))
            {
                liningDepthOpt     = value1 * scale;
                liningThicknessOpt = value2 * scale;
            }

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

            // 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) != null) &&
                (ParameterUtil.GetPositiveDoubleValueFromElementOrSymbol(familyInstance, "ThresholdThickness", out value2) != null))
            {
                thresholdDepthOpt     = value1 * scale;
                thresholdThicknessOpt = value2 * scale;
            }

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

            // 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) != null) &&
                (ParameterUtil.GetPositiveDoubleValueFromElementOrSymbol(familyInstance, "TransomThickness", out value2) != null))
            {
                transomOffsetOpt    = value1 * scale;
                transomThicknessOpt = value2 * scale;
            }

            // 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) != null) &&
                (ParameterUtil.GetPositiveDoubleValueFromElementOrSymbol(familyInstance, "CasingThickness", out value2) != null))
            {
                casingDepthOpt     = value1 * scale;
                casingThicknessOpt = value2 * scale;
            }

            string doorLiningGUID = GUIDUtil.CreateSubElementGUID(familyInstance, (int)IFCDoorSubElements.DoorLining);
            string doorLiningName = NamingUtil.GetIFCName(familyInstance);

            return(IFCInstanceExporter.CreateDoorLiningProperties(file, doorLiningGUID, ownerHistory,
                                                                  doorLiningName, null, liningDepthOpt, liningThicknessOpt, thresholdDepthOpt, thresholdThicknessOpt,
                                                                  transomThicknessOpt, transomOffsetOpt, liningOffsetOpt, thresholdOffsetOpt, casingThicknessOpt,
                                                                  casingDepthOpt, null));
        }