Пример #1
0
        /// <summary>
        /// Exports an element to IfcPile.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="element">The element.</param>
        /// <param name="geometryElement">The geometry element.</param>
        /// <param name="ifcEnumType">The string value represents the IFC type.</param>
        /// <param name="productWrapper">The ProductWrapper.</param>
        public static void ExportPile(ExporterIFC exporterIFC, Element element, GeometryElement geometryElement,
                                      string ifcEnumType, ProductWrapper productWrapper)
        {
            // NOTE: We expect to incorporate this code into the generic FamilyInstanceExporter at some point.
            // export parts or not
            bool exportParts = PartExporter.CanExportParts(element);

            if (exportParts && !PartExporter.CanExportElementInPartExport(element, element.LevelId, false))
            {
                return;
            }

            IFCFile file = exporterIFC.GetFile();

            using (IFCTransaction tr = new IFCTransaction(file))
            {
                // Check for containment override
                IFCAnyHandle overrideContainerHnd = null;
                ElementId    overrideContainerId  = ParameterUtil.OverrideContainmentParameter(exporterIFC, element, out overrideContainerHnd);

                using (PlacementSetter setter = PlacementSetter.Create(exporterIFC, element, null, null, overrideContainerId, overrideContainerHnd))
                {
                    using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
                    {
                        ecData.SetLocalPlacement(setter.LocalPlacement);

                        IFCAnyHandle prodRep = null;
                        ElementId    matId   = ElementId.InvalidElementId;
                        if (!exportParts)
                        {
                            ElementId catId = CategoryUtil.GetSafeCategoryId(element);


                            matId = BodyExporter.GetBestMaterialIdFromGeometryOrParameter(geometryElement, exporterIFC, element);
                            BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true, ExportOptionsCache.ExportTessellationLevel.ExtraLow);

                            StructuralMemberAxisInfo axisInfo = StructuralMemberExporter.GetStructuralMemberAxisTransform(element);
                            if (axisInfo != null)
                            {
                                ecData.CustomAxis            = axisInfo.AxisDirection;
                                ecData.PossibleExtrusionAxes = IFCExtrusionAxes.TryCustom;
                            }
                            else
                            {
                                ecData.PossibleExtrusionAxes = IFCExtrusionAxes.TryZ;
                            }

                            prodRep = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC,
                                                                                                 element, catId, geometryElement, bodyExporterOptions, null, ecData, true);
                            if (IFCAnyHandleUtil.IsNullOrHasNoValue(prodRep))
                            {
                                ecData.ClearOpenings();
                                return;
                            }
                        }

                        string            instanceGUID = GUIDUtil.CreateGUID(element);
                        IFCExportInfoPair exportInfo   = new IFCExportInfoPair(Common.Enums.IFCEntityType.IfcPile, ifcEnumType);

                        IFCAnyHandle pile = IFCInstanceExporter.CreatePile(exporterIFC, element, instanceGUID, ExporterCacheManager.OwnerHistoryHandle,
                                                                           ecData.GetLocalPlacement(), prodRep, ifcEnumType, null);

                        // TODO: to allow shared geometry for Piles. For now, Pile export will not use shared geometry
                        if (exportInfo.ExportType != Common.Enums.IFCEntityType.UnKnown)
                        {
                            IFCAnyHandle type = ExporterUtil.CreateGenericTypeFromElement(element, exportInfo, file, ExporterCacheManager.OwnerHistoryHandle, exportInfo.ValidatedPredefinedType, productWrapper);
                            ExporterCacheManager.TypeRelationsCache.Add(type, pile);
                        }
                        if (exportParts)
                        {
                            PartExporter.ExportHostPart(exporterIFC, element, pile, productWrapper, setter, setter.LocalPlacement, null);
                        }
                        else
                        {
                            if (matId != ElementId.InvalidElementId)
                            {
                                CategoryUtil.CreateMaterialAssociation(exporterIFC, pile, matId);
                            }
                        }

                        productWrapper.AddElement(element, pile, setter, ecData, true, exportInfo);

                        OpeningUtil.CreateOpeningsIfNecessary(pile, element, ecData, null,
                                                              exporterIFC, ecData.GetLocalPlacement(), setter, productWrapper);
                    }
                }

                tr.Commit();
            }
        }
Пример #2
0
        /// <summary>
        /// Exports an element to IfcPile.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="element">The element.</param>
        /// <param name="geometryElement">The geometry element.</param>
        /// <param name="ifcEnumType">The string value represents the IFC type.</param>
        /// <param name="productWrapper">The ProductWrapper.</param>
        public static void ExportPile(ExporterIFC exporterIFC, Element element, GeometryElement geometryElement,
                                      string ifcEnumType, ProductWrapper productWrapper)
        {
            // export parts or not
            bool exportParts = PartExporter.CanExportParts(element);

            if (exportParts && !PartExporter.CanExportElementInPartExport(element, element.LevelId, false))
            {
                return;
            }

            IFCFile file = exporterIFC.GetFile();

            using (IFCTransaction tr = new IFCTransaction(file))
            {
                using (PlacementSetter setter = PlacementSetter.Create(exporterIFC, element))
                {
                    using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
                    {
                        ecData.SetLocalPlacement(setter.LocalPlacement);

                        IFCAnyHandle prodRep = null;
                        ElementId    matId   = ElementId.InvalidElementId;
                        if (!exportParts)
                        {
                            ElementId catId = CategoryUtil.GetSafeCategoryId(element);


                            matId = BodyExporter.GetBestMaterialIdFromGeometryOrParameter(geometryElement, exporterIFC, element);
                            BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true, ExportOptionsCache.ExportTessellationLevel.ExtraLow);

                            StructuralMemberAxisInfo axisInfo = StructuralMemberExporter.GetStructuralMemberAxisTransform(element);
                            if (axisInfo != null)
                            {
                                ecData.CustomAxis            = axisInfo.AxisDirection;
                                ecData.PossibleExtrusionAxes = IFCExtrusionAxes.TryCustom;
                            }
                            else
                            {
                                ecData.PossibleExtrusionAxes = IFCExtrusionAxes.TryZ;
                            }

                            prodRep = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC,
                                                                                                 element, catId, geometryElement, bodyExporterOptions, null, ecData, true);
                            if (IFCAnyHandleUtil.IsNullOrHasNoValue(prodRep))
                            {
                                ecData.ClearOpenings();
                                return;
                            }
                        }

                        string instanceGUID = GUIDUtil.CreateGUID(element);
                        //string pileType = IFCValidateEntry.GetValidIFCPredefinedType(element, ifcEnumType);

                        IFCAnyHandle pile = IFCInstanceExporter.CreatePile(exporterIFC, element, instanceGUID, ExporterCacheManager.OwnerHistoryHandle,
                                                                           ecData.GetLocalPlacement(), prodRep, ifcEnumType, null);

                        if (exportParts)
                        {
                            PartExporter.ExportHostPart(exporterIFC, element, pile, productWrapper, setter, setter.LocalPlacement, null);
                        }
                        else
                        {
                            if (matId != ElementId.InvalidElementId)
                            {
                                CategoryUtil.CreateMaterialAssociation(exporterIFC, pile, matId);
                            }
                        }

                        productWrapper.AddElement(element, pile, setter, ecData, true);

                        OpeningUtil.CreateOpeningsIfNecessary(pile, element, ecData, null,
                                                              exporterIFC, ecData.GetLocalPlacement(), setter, productWrapper);
                    }
                }

                tr.Commit();
            }
        }