Esempio n. 1
0
 public IActionResult BuyProducts([FromBody] List <Product> products)
 {
     _lastTransaction = _transactionRepository.AddTransaction(ProductWrapper.productHistories(products), TransactionType.Bought);
     _productRepository.AddProducts(products);
     return(Ok());
 }
Esempio n. 2
0
        private static void ExportAsMappedItem(ExporterIFC exporterIFC, Element element, IFCFile file, IFCExportType exportType, string ifcEnumType, IFCExtrusionCreationData extraParams,
                                               PlacementSetter setter, IFCAnyHandle localPlacementToUse, IFCAnyHandle productRepresentation, ProductWrapper productWrapper)
        {
            IFCAnyHandle ownerHistory = ExporterCacheManager.OwnerHistoryHandle;
            ElementId    typeId       = element.GetTypeId();
            ElementType  type         = element.Document.GetElement(typeId) as ElementType;
            IFCAnyHandle styleHandle  = null;

            if (type != null)
            {
                FamilyTypeInfo currentTypeInfo = ExporterCacheManager.TypeObjectsCache.Find(typeId, false, exportType);

                bool found = currentTypeInfo.IsValid();
                if (!found)
                {
                    string typeObjectType = NamingUtil.CreateIFCObjectName(exporterIFC, type);

                    HashSet <IFCAnyHandle> propertySetsOpt = new HashSet <IFCAnyHandle>();
                    IList <IFCAnyHandle>   repMapListOpt   = new List <IFCAnyHandle>();

                    styleHandle = FamilyExporterUtil.ExportGenericType(exporterIFC, exportType, ifcEnumType, propertySetsOpt, repMapListOpt, element, type);
                    if (!IFCAnyHandleUtil.IsNullOrHasNoValue(styleHandle))
                    {
                        propertySetsOpt = ExporterUtil.ExtractElementTypeProperties(exporterIFC, type, styleHandle);
                        productWrapper.RegisterHandleWithElementType(type, styleHandle, propertySetsOpt);
                        string applicableOccurrence = NamingUtil.GetObjectTypeOverride(type, typeObjectType);
                        if (!string.IsNullOrEmpty(applicableOccurrence))
                        {
                            IFCAnyHandleUtil.SetAttribute(styleHandle, "ApplicableOccurrence", applicableOccurrence);
                        }
                        currentTypeInfo.Style = styleHandle;
                        ExporterCacheManager.TypeObjectsCache.Register(typeId, false, exportType, currentTypeInfo);
                    }
                }
                else
                {
                    styleHandle = currentTypeInfo.Style;
                }
            }

            string instanceGUID = GUIDUtil.CreateGUID(element);


            bool roomRelated = !FamilyExporterUtil.IsDistributionFlowElementSubType(exportType);

            ElementId roomId = ElementId.InvalidElementId;

            if (roomRelated)
            {
                roomId = setter.UpdateRoomRelativeCoordinates(element, out localPlacementToUse);
            }

            IFCAnyHandle instanceHandle = null;

            // For MEP objects
            string exportEntityStr = exportType.ToString();

            Common.Enums.IFCEntityType exportEntity;

            if (String.Compare(exportEntityStr.Substring(exportEntityStr.Length - 4), "Type", true) == 0)
            {
                exportEntityStr = exportEntityStr.Substring(0, (exportEntityStr.Length - 4));
            }
            if (Enum.TryParse(exportEntityStr, out exportEntity))
            {
                // For MEP object creation
                instanceHandle = IFCInstanceExporter.CreateGenericIFCEntity(exportEntity, exporterIFC, element, instanceGUID, ownerHistory,
                                                                            localPlacementToUse, productRepresentation);
            }

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

            if (roomId != ElementId.InvalidElementId)
            {
                //exporterIFC.RelateSpatialElement(roomId, instanceHandle);
                ExporterCacheManager.SpaceInfoCache.RelateToSpace(roomId, instanceHandle);
                productWrapper.AddElement(element, instanceHandle, setter, extraParams, false);
            }
            else
            {
                productWrapper.AddElement(element, instanceHandle, setter, extraParams, true);
            }

            OpeningUtil.CreateOpeningsIfNecessary(instanceHandle, element, extraParams, null, exporterIFC, localPlacementToUse, setter, productWrapper);

            if (!IFCAnyHandleUtil.IsNullOrHasNoValue(styleHandle))
            {
                ExporterCacheManager.TypeRelationsCache.Add(styleHandle, instanceHandle);
            }

            PropertyUtil.CreateInternalRevitPropertySets(exporterIFC, element, productWrapper.GetAllObjects());

            ExporterCacheManager.MEPCache.Register(element, instanceHandle);

            // add to system export cache
            // SystemExporter.ExportSystem(exporterIFC, element, instanceHandle);
        }
Esempio n. 3
0
        /// <summary>
        /// Exports a MEP family instance.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="element">The element.</param>
        /// <param name="geometryElement">The geometry element.</param>
        /// <param name="exportType">The export type of the element.
        /// <param name="ifcEnumType">The sub-type of the element.</param></param>
        /// <param name="productWrapper">The ProductWrapper.</param>
        /// <returns>True if an entity was created, false otherwise.</returns>
        public static bool Export(ExporterIFC exporterIFC, Element element, GeometryElement geometryElement,
                                  IFCExportType exportType, string ifcEnumType, ProductWrapper productWrapper)
        {
            IFCFile file = exporterIFC.GetFile();

            using (IFCTransaction tr = new IFCTransaction(file))
            {
                // CQ_TODO: Clean up this code by at least factoring it out.

                // If we are exporting a duct segment, we may need to split it into parts by level. Create a list of ranges.
                IList <ElementId> levels = new List <ElementId>();
                IList <IFCRange>  ranges = new List <IFCRange>();

                // We will not split duct segments if the assemblyId is set, as we would like to keep the original duct segment
                // associated with the assembly, on the level of the assembly.
                if ((exportType == IFCExportType.IfcDuctSegmentType) &&
                    (ExporterCacheManager.ExportOptionsCache.WallAndColumnSplitting) &&
                    (element.AssemblyInstanceId == ElementId.InvalidElementId))
                {
                    LevelUtil.CreateSplitLevelRangesForElement(exporterIFC, exportType, element, out levels,
                                                               out ranges);
                }

                int numPartsToExport = ranges.Count;
                {
                    ElementId catId = CategoryUtil.GetSafeCategoryId(element);

                    BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true, ExportOptionsCache.ExportTessellationLevel.ExtraLow);
                    if (0 == numPartsToExport)
                    {
                        using (PlacementSetter setter = PlacementSetter.Create(exporterIFC, element))
                        {
                            IFCAnyHandle localPlacementToUse = setter.LocalPlacement;
                            BodyData     bodyData            = null;
                            using (IFCExtrusionCreationData extraParams = new IFCExtrusionCreationData())
                            {
                                extraParams.SetLocalPlacement(localPlacementToUse);
                                IFCAnyHandle productRepresentation =
                                    RepresentationUtil.CreateAppropriateProductDefinitionShape(
                                        exporterIFC, element, catId, geometryElement, bodyExporterOptions, null, extraParams, out bodyData);
                                if (IFCAnyHandleUtil.IsNullOrHasNoValue(productRepresentation))
                                {
                                    extraParams.ClearOpenings();
                                    return(false);
                                }

                                ExportAsMappedItem(exporterIFC, element, file, exportType, ifcEnumType, extraParams,
                                                   setter, localPlacementToUse, productRepresentation,
                                                   productWrapper);
                            }
                        }
                    }
                    else
                    {
                        for (int ii = 0; ii < numPartsToExport; ii++)
                        {
                            using (PlacementSetter setter = PlacementSetter.Create(exporterIFC, element, null, null, levels[ii]))
                            {
                                IFCAnyHandle localPlacementToUse = setter.LocalPlacement;

                                using (IFCExtrusionCreationData extraParams = new IFCExtrusionCreationData())
                                {
                                    SolidMeshGeometryInfo solidMeshCapsule =
                                        GeometryUtil.GetClippedSolidMeshGeometry(geometryElement, ranges[ii]);

                                    IList <Solid> solids     = solidMeshCapsule.GetSolids();
                                    IList <Mesh>  polyMeshes = solidMeshCapsule.GetMeshes();

                                    IList <GeometryObject> geomObjects =
                                        FamilyExporterUtil.RemoveInvisibleSolidsAndMeshes(element.Document,
                                                                                          exporterIFC, solids, polyMeshes);

                                    if (geomObjects.Count == 0 && (solids.Count > 0 || polyMeshes.Count > 0))
                                    {
                                        return(false);
                                    }

                                    bool tryToExportAsExtrusion = (!exporterIFC.ExportAs2x2 ||
                                                                   (exportType == IFCExportType.IfcColumnType));

                                    if (exportType == IFCExportType.IfcColumnType)
                                    {
                                        extraParams.PossibleExtrusionAxes = IFCExtrusionAxes.TryZ;
                                    }
                                    else
                                    {
                                        extraParams.PossibleExtrusionAxes = IFCExtrusionAxes.TryXYZ;
                                    }

                                    BodyData bodyData = null;
                                    if (geomObjects.Count > 0)
                                    {
                                        bodyData = BodyExporter.ExportBody(exporterIFC, element, catId,
                                                                           ElementId.InvalidElementId, geomObjects,
                                                                           bodyExporterOptions, extraParams);
                                    }
                                    else
                                    {
                                        IList <GeometryObject> exportedGeometries = new List <GeometryObject>();
                                        exportedGeometries.Add(geometryElement);
                                        bodyData = BodyExporter.ExportBody(exporterIFC, element, catId,
                                                                           ElementId.InvalidElementId,
                                                                           exportedGeometries, bodyExporterOptions,
                                                                           extraParams);
                                    }

                                    List <IFCAnyHandle> bodyReps = new List <IFCAnyHandle>();
                                    bodyReps.Add(bodyData.RepresentationHnd);

                                    IFCAnyHandle productRepresentation =
                                        IFCInstanceExporter.CreateProductDefinitionShape(exporterIFC.GetFile(), null,
                                                                                         null, bodyReps);
                                    if (IFCAnyHandleUtil.IsNullOrHasNoValue(productRepresentation))
                                    {
                                        extraParams.ClearOpenings();
                                        return(false);
                                    }

                                    ExportAsMappedItem(exporterIFC, element, file, exportType, ifcEnumType,
                                                       extraParams, setter, localPlacementToUse,
                                                       productRepresentation, productWrapper);
                                }
                            }
                        }
                    }
                }

                tr.Commit();
            }
            return(true);
        }
Esempio n. 4
0
        /// <summary>
        /// Exports a hosted weep.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="hostedSweep">The hosted sweep element.</param>
        /// <param name="geometryElement">The geometry element.</param>
        /// <param name="productWrapper">The ProductWrapper.</param>
        public static void Export(ExporterIFC exporterIFC, HostedSweep hostedSweep, GeometryElement geometryElement, ProductWrapper productWrapper)
        {
            ElementId catId = CategoryUtil.GetSafeCategoryId(hostedSweep);

            if (catId == new ElementId(BuiltInCategory.OST_Gutter))
            {
                ExportGutter(exporterIFC, hostedSweep, geometryElement, productWrapper);
            }
            else
            {
                ProxyElementExporter.Export(exporterIFC, hostedSweep, geometryElement, productWrapper);
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Exports topography surface as IFC site object.
 /// </summary>
 /// <param name="exporterIFC">The ExporterIFC object.</param>
 /// <param name="topoSurface">The TopographySurface object.</param>
 /// <param name="geometryElement">The geometry element.</param>
 /// <param name="productWrapper">The ProductWrapper.</param>
 public static void ExportTopographySurface(ExporterIFC exporterIFC, TopographySurface topoSurface, GeometryElement geometryElement, ProductWrapper productWrapper)
 {
     ExportSiteBase(exporterIFC, null, topoSurface, geometryElement, productWrapper);
 }
Esempio n. 6
0
        /// <summary>
        /// Exports a roof to IfcRoof.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="roof">The roof element.</param>
        /// <param name="geometryElement">The geometry element.</param>
        /// <param name="productWrapper">The ProductWrapper.</param>
        public static void Export(ExporterIFC exporterIFC, RoofBase roof, GeometryElement geometryElement, ProductWrapper productWrapper)
        {
            IFCFile file = exporterIFC.GetFile();

            using (IFCTransaction tr = new IFCTransaction(file))
            {
                // export parts or not
                bool exportParts         = PartExporter.CanExportParts(roof);
                bool exportAsCurtainRoof = CurtainSystemExporter.IsCurtainSystem(roof);

                if (exportParts)
                {
                    if (!PartExporter.CanExportElementInPartExport(roof, roof.LevelId, false))
                    {
                        return;
                    }
                    ExportRoofAsParts(exporterIFC, roof, geometryElement, productWrapper); // Right now, only flat roof could have parts.
                }
                else if (exportAsCurtainRoof)
                {
                    CurtainSystemExporter.ExportCurtainRoof(exporterIFC, roof, productWrapper);
                }
                else
                {
                    string ifcEnumType = ExporterUtil.GetIFCTypeFromExportTable(exporterIFC, roof);

                    IFCAnyHandle roofHnd = ExportRoofAsContainer(exporterIFC, ifcEnumType, roof,
                                                                 geometryElement, productWrapper);
                    if (IFCAnyHandleUtil.IsNullOrHasNoValue(roofHnd))
                    {
                        ExportRoof(exporterIFC, ifcEnumType, roof, geometryElement, productWrapper);
                    }

                    // call for host objects; curtain roofs excused from call (no material information)
                    HostObjectExporter.ExportHostObjectMaterials(exporterIFC, roof, productWrapper.GetAnElement(),
                                                                 geometryElement, productWrapper, ElementId.InvalidElementId, IFCLayerSetDirection.Axis3, null);
                }
                tr.Commit();
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Export the roof to IfcRoof containing its parts.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="element">The roof element.</param>
        /// <param name="geometryElement">The geometry element.</param>
        /// <param name="productWrapper">The ProductWrapper.</param>
        public static void ExportRoofAsParts(ExporterIFC exporterIFC, Element element, GeometryElement geometryElement, ProductWrapper productWrapper)
        {
            IFCFile file = exporterIFC.GetFile();

            using (IFCTransaction transaction = new IFCTransaction(file))
            {
                using (PlacementSetter setter = PlacementSetter.Create(exporterIFC, element))
                {
                    IFCAnyHandle ownerHistory   = ExporterCacheManager.OwnerHistoryHandle;
                    IFCAnyHandle localPlacement = setter.LocalPlacement;

                    IFCAnyHandle prodRepHnd = null;

                    string elementGUID        = GUIDUtil.CreateGUID(element);
                    string elementName        = NamingUtil.GetNameOverride(element, NamingUtil.GetIFCName(element));
                    string elementDescription = NamingUtil.GetDescriptionOverride(element, null);
                    string elementObjectType  = NamingUtil.GetObjectTypeOverride(element, exporterIFC.GetFamilyName());
                    string elementTag         = NamingUtil.GetTagOverride(element, NamingUtil.CreateIFCElementId(element));

                    //need to convert the string to enum
                    string ifcEnumType = ExporterUtil.GetIFCTypeFromExportTable(exporterIFC, element);
                    ifcEnumType = IFCValidateEntry.GetValidIFCType(element, ifcEnumType);

                    IFCAnyHandle roofHandle = IFCInstanceExporter.CreateRoof(file, elementGUID, ownerHistory, elementName, elementDescription,
                                                                             elementObjectType, localPlacement, prodRepHnd, elementTag, ifcEnumType);

                    // Export the parts
                    PartExporter.ExportHostPart(exporterIFC, element, roofHandle, productWrapper, setter, localPlacement, null);

                    productWrapper.AddElement(element, roofHandle, setter, null, true);

                    transaction.Commit();
                }
            }
        }
Esempio n. 8
0
        private void NewProduct()
        {
            SelectedProduct = null;
            GetProductAttributes();
            Client.Entities.Product product = new Client.Entities.Product();

            var price_att_type = _prod_att_list.Where(item => item.AttributeTypeCode == "PRODBASE").FirstOrDefault();
            var cost_att_type  = _prod_att_list.Where(item => item.AttributeTypeCode == "PRODCOST").FirstOrDefault();
            var qty_att_type   = _prod_att_list.Where(item => item.AttributeTypeCode == "PRODDFQTY").FirstOrDefault();
            var inc_att_type   = _prod_att_list.Where(item => item.AttributeTypeCode == "INCACCT").FirstOrDefault();
            var exp_att_type   = _prod_att_list.Where(item => item.AttributeTypeCode == "EXPACCT").FirstOrDefault();

            EntityAttribute price = new EntityAttribute()
            {
                AttributeDataType      = QIQOAttributeDataType.Money,
                AttributeDataTypeKey   = (int)QIQOAttributeDataType.Money,
                AttributeDisplayFormat = price_att_type.AttributeDefaultFormat,
                AttributeType          = QIQOAttributeType.Product_PRODBASE,
                AttributeValue         = "30.00",
                EntityKey         = 0,
                EntityType        = QIQOEntityType.Product,
                AttributeKey      = 0,
                AttributeTypeData = price_att_type
            };

            product.ProductAttributes.Add(price);

            EntityAttribute cost = new EntityAttribute()
            {
                AttributeDataType      = QIQOAttributeDataType.Money,
                AttributeDataTypeKey   = (int)QIQOAttributeDataType.Money,
                AttributeDisplayFormat = cost_att_type.AttributeDefaultFormat,
                AttributeType          = QIQOAttributeType.Product_PRODCOST,
                AttributeValue         = "10.00",
                EntityKey         = 0,
                EntityType        = QIQOEntityType.Product,
                AttributeKey      = 0,
                AttributeTypeData = cost_att_type
            };

            product.ProductAttributes.Add(cost);

            EntityAttribute qty = new EntityAttribute()
            {
                AttributeDataType      = QIQOAttributeDataType.Number,
                AttributeDataTypeKey   = (int)QIQOAttributeDataType.Number,
                AttributeDisplayFormat = qty_att_type.AttributeDefaultFormat,
                AttributeType          = QIQOAttributeType.Product_PRODDFQTY,
                AttributeValue         = "1",
                EntityKey         = 0,
                EntityType        = QIQOEntityType.Product,
                AttributeKey      = 0,
                AttributeTypeData = qty_att_type
            };

            product.ProductAttributes.Add(qty);

            EntityAttribute inc_acct = new EntityAttribute()
            {
                AttributeDataType      = QIQOAttributeDataType.String,
                AttributeDataTypeKey   = (int)QIQOAttributeDataType.String,
                AttributeDisplayFormat = inc_att_type.AttributeDefaultFormat,
                AttributeType          = QIQOAttributeType.Product_INCACCT,
                AttributeValue         = "4000",
                EntityKey         = 0,
                EntityType        = QIQOEntityType.Product,
                AttributeKey      = 0,
                AttributeTypeData = inc_att_type
            };

            product.ProductAttributes.Add(inc_acct);

            EntityAttribute exp_acct = new EntityAttribute()
            {
                AttributeDataType      = QIQOAttributeDataType.String,
                AttributeDataTypeKey   = (int)QIQOAttributeDataType.String,
                AttributeDisplayFormat = exp_att_type.AttributeDefaultFormat,
                AttributeType          = QIQOAttributeType.Product_EXPACCT,
                AttributeValue         = "4300",
                EntityKey         = 0,
                EntityType        = QIQOEntityType.Product,
                AttributeKey      = 0,
                AttributeTypeData = exp_att_type
            };

            product.ProductAttributes.Add(exp_acct);

            ProductWrapper new_product = new ProductWrapper(product);

            new_product.PropertyChanged += Context_PropertyChanged;
            SelectedProduct              = new_product;
            event_aggregator.GetEvent <ProductNewProductAddEvent>().Publish(ViewNames.ProductHomeView);
        }
 /// <summary>
 /// Exports a curtain roof to IFC curtain wall.
 /// </summary>
 /// <param name="exporterIFC">The ExporterIFC object.</param>
 /// <param name="hostElement">The host object element to be exported.</param>
 /// <param name="productWrapper">The ProductWrapper.</param>
 public static void ExportCurtainRoof(ExporterIFC exporterIFC, RoofBase hostElement, ProductWrapper productWrapper)
 {
     ExportBaseWithGrids(exporterIFC, hostElement, productWrapper);
 }
        /// <summary>
        /// Exports an element as an IfcReinforcingMesh.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="element">The element.</param>
        /// <param name="geometryElement">The geometry element.</param>
        /// <param name="productWrapper">The ProductWrapper.</param>
        /// <returns>True if exported successfully, false otherwise.</returns>
        public static bool ExportFabricSheet(ExporterIFC exporterIFC, FabricSheet sheet,
                                             GeometryElement geometryElement, ProductWrapper productWrapper)
        {
            if (sheet == null || geometryElement == null)
            {
                return(false);
            }

            Document doc  = sheet.Document;
            IFCFile  file = exporterIFC.GetFile();

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

                        ElementId categoryId = CategoryUtil.GetSafeCategoryId(sheet);

                        ElementId materialId = ElementId.InvalidElementId;
                        ParameterUtil.GetElementIdValueFromElementOrSymbol(sheet, BuiltInParameter.MATERIAL_ID_PARAM, out materialId);

                        string       guid            = GUIDUtil.CreateGUID(sheet);
                        IFCAnyHandle ownerHistory    = ExporterCacheManager.OwnerHistoryHandle;
                        string       revitObjectType = exporterIFC.GetFamilyName();
                        string       name            = NamingUtil.GetNameOverride(sheet, revitObjectType);
                        string       description     = NamingUtil.GetDescriptionOverride(sheet, null);
                        string       objectType      = NamingUtil.GetObjectTypeOverride(sheet, revitObjectType);

                        IFCAnyHandle localPlacement = ecData.GetLocalPlacement();
                        string       elementTag     = NamingUtil.CreateIFCElementId(sheet);

                        string steelGrade = NamingUtil.GetOverrideStringValue(sheet, "SteelGrade", null);
                        double?meshLength = sheet.CutOverallLength;
                        double?meshWidth  = sheet.CutOverallWidth;

                        Element         fabricSheetTypeElem = doc.GetElement(sheet.GetTypeId());
                        FabricSheetType fabricSheetType     = (fabricSheetTypeElem == null) ? null : (fabricSheetTypeElem as FabricSheetType);

                        double longitudinalBarNominalDiameter  = 0.0;
                        double transverseBarNominalDiameter    = 0.0;
                        double longitudinalBarCrossSectionArea = 0.0;
                        double transverseBarCrossSectionArea   = 0.0;
                        double longitudinalBarSpacing          = 0.0;
                        double transverseBarSpacing            = 0.0;
                        if (fabricSheetType != null)
                        {
                            Element        majorFabricWireTypeElem = doc.GetElement(fabricSheetType.MajorDirectionWireType);
                            FabricWireType majorFabricWireType     = (majorFabricWireTypeElem == null) ? null : (majorFabricWireTypeElem as FabricWireType);
                            if (majorFabricWireType != null)
                            {
                                longitudinalBarNominalDiameter = UnitUtil.ScaleLength(majorFabricWireType.WireDiameter);
                                double localRadius = longitudinalBarNominalDiameter / 2.0;
                                longitudinalBarCrossSectionArea = localRadius * localRadius * Math.PI;
                            }

                            Element        minorFabricWireTypeElem = doc.GetElement(fabricSheetType.MinorDirectionWireType);
                            FabricWireType minorFabricWireType     = (minorFabricWireTypeElem == null) ? null : (minorFabricWireTypeElem as FabricWireType);
                            if (minorFabricWireType != null)
                            {
                                transverseBarNominalDiameter = UnitUtil.ScaleLength(minorFabricWireType.WireDiameter);
                                double localRadius = transverseBarNominalDiameter / 2.0;
                                transverseBarCrossSectionArea = localRadius * localRadius * Math.PI;
                            }

                            longitudinalBarSpacing = UnitUtil.ScaleLength(fabricSheetType.MajorSpacing);
                            transverseBarSpacing   = UnitUtil.ScaleLength(fabricSheetType.MinorSpacing);
                        }

                        ISet <IFCAnyHandle> bodyItems = new HashSet <IFCAnyHandle>();

                        IList <Curve> wireCenterlines = sheet.GetWireCenterlines(WireDistributionDirection.Major);
                        foreach (Curve wireCenterline in wireCenterlines)
                        {
                            IFCAnyHandle bodyItem = GeometryUtil.CreateSweptDiskSolid(exporterIFC, file, wireCenterline, longitudinalBarNominalDiameter, null);
                            if (!IFCAnyHandleUtil.IsNullOrHasNoValue(bodyItem))
                            {
                                bodyItems.Add(bodyItem);
                            }
                        }

                        wireCenterlines = sheet.GetWireCenterlines(WireDistributionDirection.Minor);
                        foreach (Curve wireCenterline in wireCenterlines)
                        {
                            IFCAnyHandle bodyItem = GeometryUtil.CreateSweptDiskSolid(exporterIFC, file, wireCenterline, transverseBarNominalDiameter, null);
                            if (!IFCAnyHandleUtil.IsNullOrHasNoValue(bodyItem))
                            {
                                bodyItems.Add(bodyItem);
                            }
                        }

                        IFCAnyHandle shapeRep = (bodyItems.Count > 0) ?
                                                RepresentationUtil.CreateAdvancedSweptSolidRep(exporterIFC, sheet, categoryId, exporterIFC.Get3DContextHandle("Body"), bodyItems, null) :
                                                null;
                        IList <IFCAnyHandle> shapeReps = null;
                        if (shapeRep != null)
                        {
                            shapeReps = new List <IFCAnyHandle>();
                            shapeReps.Add(shapeRep);
                        }
                        IFCAnyHandle prodRep = (shapeReps != null) ? IFCInstanceExporter.CreateProductDefinitionShape(file, null, null, shapeReps) : null;

                        IFCAnyHandle fabricSheet = IFCInstanceExporter.CreateReinforcingMesh(file, guid,
                                                                                             ownerHistory, name, description, objectType, localPlacement, prodRep, elementTag,
                                                                                             steelGrade, meshLength, meshWidth, longitudinalBarNominalDiameter, transverseBarNominalDiameter,
                                                                                             longitudinalBarCrossSectionArea, transverseBarCrossSectionArea,
                                                                                             longitudinalBarSpacing, transverseBarSpacing);

                        ElementId fabricAreaId = sheet.FabricAreaOwnerId;
                        if (fabricAreaId != ElementId.InvalidElementId)
                        {
                            HashSet <IFCAnyHandle> fabricSheets = null;
                            if (!ExporterCacheManager.FabricAreaHandleCache.TryGetValue(fabricAreaId, out fabricSheets))
                            {
                                fabricSheets = new HashSet <IFCAnyHandle>();
                                ExporterCacheManager.FabricAreaHandleCache[fabricAreaId] = fabricSheets;
                            }
                            fabricSheets.Add(fabricSheet);
                        }

                        productWrapper.AddElement(sheet, fabricSheet, placementSetter.LevelInfo, ecData, true);

                        CategoryUtil.CreateMaterialAssociation(exporterIFC, fabricSheet, materialId);
                    }
                }
                tr.Commit();
                return(true);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Exports mullion.
        /// </summary>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="mullion">
        /// The mullion object.
        /// </param>
        /// <param name="geometryElement">
        /// The geometry element.
        /// </param>
        /// <param name="localPlacement">
        /// The local placement handle.
        /// </param>
        /// <param name="setter">
        /// The PlacementSetter.
        /// </param>
        /// <param name="productWrapper">
        /// The ProductWrapper.
        /// </param>
        public static void Export(ExporterIFC exporterIFC, Mullion mullion, GeometryElement geometryElement,
                                  IFCAnyHandle localPlacement, PlacementSetter setter, ProductWrapper productWrapper)
        {
            IFCFile file = exporterIFC.GetFile();

            using (PlacementSetter mullionSetter = PlacementSetter.Create(exporterIFC, mullion))
            {
                using (IFCExtrusionCreationData extraParams = new IFCExtrusionCreationData())
                {
                    IFCAnyHandle mullionPlacement = mullionSetter.LocalPlacement;

                    Transform relTrf     = ExporterIFCUtils.GetRelativeLocalPlacementOffsetTransform(localPlacement, mullionPlacement);
                    Transform inverseTrf = relTrf.Inverse;

                    IFCAnyHandle mullionLocalPlacement = ExporterUtil.CreateLocalPlacement(file, localPlacement,
                                                                                           inverseTrf.Origin, inverseTrf.BasisZ, inverseTrf.BasisX);

                    extraParams.SetLocalPlacement(mullionLocalPlacement);

                    Transform extrusionLCS = null;
                    // Add a custom direction for trying to create an extrusion based on the base curve of the mullion, if it is a line and not an arc.
                    Curve baseCurve = mullion.LocationCurve;
                    if ((baseCurve != null) && (baseCurve is Line))
                    {
                        // We won't use curveBounds and origin yet; just need the axis for now.
                        IFCRange curveBounds;
                        XYZ      origin, mullionDirection;
                        GeometryUtil.GetAxisAndRangeFromCurve(baseCurve, out curveBounds, out mullionDirection, out origin);

                        // approx 1.0/sqrt(2.0)
                        XYZ planeY = (Math.Abs(mullionDirection.Z) < 0.707) ? XYZ.BasisZ.CrossProduct(mullionDirection) : XYZ.BasisX.CrossProduct(mullionDirection);
                        planeY.Normalize();

                        XYZ projDir = mullionDirection.CrossProduct(planeY);

                        extrusionLCS        = Transform.Identity;
                        extrusionLCS.BasisX = mullionDirection; extrusionLCS.BasisY = planeY; extrusionLCS.BasisZ = projDir; extrusionLCS.Origin = origin;
                    }

                    ElementId catId = CategoryUtil.GetSafeCategoryId(mullion);

                    BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
                    bodyExporterOptions.ExtrusionLocalCoordinateSystem = extrusionLCS;

                    IFCAnyHandle repHnd = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC, mullion, catId,
                                                                                                     geometryElement, bodyExporterOptions, null, extraParams, true);
                    if (IFCAnyHandleUtil.IsNullOrHasNoValue(repHnd))
                    {
                        extraParams.ClearOpenings();
                        return;
                    }

                    string       elemGUID       = GUIDUtil.CreateGUID(mullion);
                    IFCAnyHandle ownerHistory   = exporterIFC.GetOwnerHistoryHandle();
                    string       elemObjectType = NamingUtil.CreateIFCObjectName(exporterIFC, mullion);
                    string       name           = NamingUtil.GetNameOverride(mullion, elemObjectType);
                    string       description    = NamingUtil.GetDescriptionOverride(mullion, null);
                    string       objectType     = NamingUtil.GetObjectTypeOverride(mullion, elemObjectType);
                    string       elemTag        = NamingUtil.GetTagOverride(mullion, NamingUtil.CreateIFCElementId(mullion));

                    IFCAnyHandle mullionHnd = IFCInstanceExporter.CreateMember(file, elemGUID, ownerHistory, name, description, objectType,
                                                                               mullionLocalPlacement, repHnd, elemTag, "MULLION");
                    ExporterCacheManager.HandleToElementCache.Register(mullionHnd, mullion.Id);

                    productWrapper.AddElement(mullion, mullionHnd, mullionSetter, extraParams, false);

                    ElementId matId = BodyExporter.GetBestMaterialIdFromGeometryOrParameter(geometryElement, exporterIFC, mullion);
                    CategoryUtil.CreateMaterialAssociation(exporterIFC, mullionHnd, matId);
                }
            }
        }
        /// <summary>
        /// Exports a FabricArea as an IfcGroup.  There is no geometry to export.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="element">The element.</param>
        /// <param name="productWrapper">The ProductWrapper.</param>
        /// <returns>True if exported successfully, false otherwise.</returns>
        public static bool ExportFabricArea(ExporterIFC exporterIFC, Element element, ProductWrapper productWrapper)
        {
            if (element == null)
            {
                return(false);
            }

            HashSet <IFCAnyHandle> fabricSheetHandles = null;

            if (!ExporterCacheManager.FabricAreaHandleCache.TryGetValue(element.Id, out fabricSheetHandles))
            {
                return(false);
            }

            if (fabricSheetHandles == null || fabricSheetHandles.Count == 0)
            {
                return(false);
            }

            IFCFile file = exporterIFC.GetFile();

            using (IFCTransaction tr = new IFCTransaction(file))
            {
                string       guid            = GUIDUtil.CreateGUID(element);
                IFCAnyHandle ownerHistory    = ExporterCacheManager.OwnerHistoryHandle;
                string       revitObjectType = exporterIFC.GetFamilyName();
                string       name            = NamingUtil.GetNameOverride(element, revitObjectType);
                string       description     = NamingUtil.GetDescriptionOverride(element, null);
                string       objectType      = NamingUtil.GetObjectTypeOverride(element, revitObjectType);

                IFCAnyHandle fabricArea = IFCInstanceExporter.CreateGroup(file, guid,
                                                                          ownerHistory, name, description, objectType);

                productWrapper.AddElement(element, fabricArea);

                IFCInstanceExporter.CreateRelAssignsToGroup(file, GUIDUtil.CreateGUID(), ownerHistory,
                                                            null, null, fabricSheetHandles, null, fabricArea);

                tr.Commit();
                return(true);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Base implementation to export IFC site object.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="document">The Revit document.  It may be null if element isn't.</param>
        /// <param name="element">The element.  It may be null if document isn't.</param>
        /// <param name="geometryElement">The geometry element.</param>
        /// <param name="productWrapper">The ProductWrapper.</param>
        private static void ExportSiteBase(ExporterIFC exporterIFC, Document document, Element element, GeometryElement geometryElement, ProductWrapper productWrapper)
        {
            IFCAnyHandle siteHandle = ExporterCacheManager.SiteHandle;

            int numSiteElements = (!IFCAnyHandleUtil.IsNullOrHasNoValue(siteHandle) ? 1 : 0);

            if (element == null && (numSiteElements != 0))
            {
                return;
            }

            Document doc = document;

            if (doc == null)
            {
                if (element != null)
                {
                    doc = element.Document;
                }
                else
                {
                    throw new ArgumentException("Both document and element are null.");
                }
            }

            IFCFile file = exporterIFC.GetFile();

            using (IFCTransaction tr = new IFCTransaction(file))
            {
                IFCAnyHandle siteRepresentation = null;
                if (element != null)
                {
                    // It would be possible that they actually represent several different sites with different buildings,
                    // but until we have a concept of a building in Revit, we have to assume 0-1 sites, 1 building.
                    bool appendedToSite     = false;
                    bool exportAsFacetation = !ExporterCacheManager.ExportOptionsCache.ExportAsCoordinationView2;
                    if (!IFCAnyHandleUtil.IsNullOrHasNoValue(siteHandle))
                    {
                        IList <IFCAnyHandle> representations = IFCAnyHandleUtil.GetProductRepresentations(siteHandle);
                        if (representations.Count > 0)
                        {
                            IFCAnyHandle bodyRep     = representations[0];
                            IFCAnyHandle boundaryRep = null;
                            if (representations.Count > 1)
                            {
                                boundaryRep = representations[1];
                            }

                            siteRepresentation = RepresentationUtil.CreateSurfaceProductDefinitionShape(exporterIFC, element, geometryElement, true, exportAsFacetation, ref bodyRep, ref boundaryRep);
                            if (representations.Count == 1 && !IFCAnyHandleUtil.IsNullOrHasNoValue(boundaryRep))
                            {
                                // If the first site has no boundaryRep,
                                // we will add the boundaryRep from second site to it.
                                representations.Clear();
                                representations.Add(boundaryRep);
                                IFCAnyHandleUtil.AddProductRepresentations(siteHandle, representations);
                            }
                            appendedToSite = true;
                        }
                    }

                    if (!appendedToSite)
                    {
                        siteRepresentation = RepresentationUtil.CreateSurfaceProductDefinitionShape(exporterIFC, element, geometryElement, true, exportAsFacetation);
                    }
                }

                List <int>      latitude     = new List <int>();
                List <int>      longitude    = new List <int>();
                ProjectLocation projLocation = doc.ActiveProjectLocation;

                IFCAnyHandle relativePlacement = null;
                double       unscaledElevation = 0.0;
                if (projLocation != null)
                {
                    const double scaleToDegrees = 180 / Math.PI;
                    double       latitudeInDeg  = projLocation.SiteLocation.Latitude * scaleToDegrees;
                    double       longitudeInDeg = projLocation.SiteLocation.Longitude * scaleToDegrees;

                    ExporterUtil.GetSafeProjectPositionElevation(doc, out unscaledElevation);

                    int latDeg     = ((int)latitudeInDeg); latitudeInDeg -= latDeg; latitudeInDeg *= 60;
                    int latMin     = ((int)latitudeInDeg); latitudeInDeg -= latMin; latitudeInDeg *= 60;
                    int latSec     = ((int)latitudeInDeg); latitudeInDeg -= latSec; latitudeInDeg *= 1000000;
                    int latFracSec = ((int)latitudeInDeg);
                    latitude.Add(latDeg);
                    latitude.Add(latMin);
                    latitude.Add(latSec);
                    if (!ExporterCacheManager.ExportOptionsCache.ExportAs2x2)
                    {
                        latitude.Add(latFracSec);
                    }

                    int longDeg     = ((int)longitudeInDeg); longitudeInDeg -= longDeg; longitudeInDeg *= 60;
                    int longMin     = ((int)longitudeInDeg); longitudeInDeg -= longMin; longitudeInDeg *= 60;
                    int longSec     = ((int)longitudeInDeg); longitudeInDeg -= longSec; longitudeInDeg *= 1000000;
                    int longFracSec = ((int)longitudeInDeg);
                    longitude.Add(longDeg);
                    longitude.Add(longMin);
                    longitude.Add(longSec);
                    if (!ExporterCacheManager.ExportOptionsCache.ExportAs2x2)
                    {
                        longitude.Add(longFracSec);
                    }

                    Transform siteSharedCoordinatesTrf = projLocation.GetTransform().Inverse;
                    if (!siteSharedCoordinatesTrf.IsIdentity)
                    {
                        double unscaledSiteElevation = ExporterCacheManager.ExportOptionsCache.IncludeSiteElevation ? 0.0 : unscaledElevation;
                        XYZ    orig = UnitUtil.ScaleLength(siteSharedCoordinatesTrf.Origin - new XYZ(0, 0, unscaledSiteElevation));
                        relativePlacement = ExporterUtil.CreateAxis2Placement3D(file, orig, siteSharedCoordinatesTrf.BasisZ, siteSharedCoordinatesTrf.BasisX);
                    }
                }

                // Get elevation for site.
                double elevation = UnitUtil.ScaleLength(unscaledElevation);

                if (IFCAnyHandleUtil.IsNullOrHasNoValue(relativePlacement))
                {
                    relativePlacement = ExporterUtil.CreateAxis2Placement3D(file);
                }

                IFCAnyHandle localPlacement = IFCInstanceExporter.CreateLocalPlacement(file, null, relativePlacement);
                IFCAnyHandle ownerHistory   = ExporterCacheManager.OwnerHistoryHandle;
                string       siteObjectType = NamingUtil.CreateIFCObjectName(exporterIFC, element);

                ProjectInfo projectInfo     = doc.ProjectInformation;
                Element     mainSiteElement = (element != null) ? element : projectInfo;

                bool   exportSite          = false;
                string siteGUID            = null;
                string siteName            = null;
                string siteLongName        = null;
                string siteLandTitleNumber = null;
                string siteDescription     = null;

                if (element != null)
                {
                    if (IFCAnyHandleUtil.IsNullOrHasNoValue(siteHandle))
                    {
                        exportSite = true;

                        // We will use the Project Information site name as the primary name, if it exists.
                        siteGUID = GUIDUtil.CreateSiteGUID(doc, element);

                        siteName        = NamingUtil.GetOverrideStringValue(projectInfo, "SiteName", NamingUtil.GetNameOverride(element, NamingUtil.GetIFCName(element)));
                        siteDescription = NamingUtil.GetDescriptionOverride(element, null);
                        siteObjectType  = NamingUtil.GetObjectTypeOverride(element, siteObjectType);

                        // Look in site element for "IfcLongName" or project information for either "IfcLongName" or "SiteLongName".
                        siteLongName = NamingUtil.GetLongNameOverride(projectInfo, NamingUtil.GetLongNameOverride(element, null));
                        if (string.IsNullOrWhiteSpace(siteLongName))
                        {
                            siteLongName = NamingUtil.GetOverrideStringValue(projectInfo, "SiteLongName", null);
                        }

                        // Look in site element for "IfcLandTitleNumber" or project information for "SiteLandTitleNumber".
                        siteLandTitleNumber = NamingUtil.GetOverrideStringValue(element, "IfcLandTitleNumber", null);
                        if (string.IsNullOrWhiteSpace(siteLandTitleNumber))
                        {
                            siteLandTitleNumber = NamingUtil.GetOverrideStringValue(projectInfo, "SiteLandTitleNumber", null);
                        }
                    }
                }
                else
                {
                    exportSite = true;

                    siteGUID            = GUIDUtil.CreateProjectLevelGUID(doc, IFCProjectLevelGUIDType.Site);
                    siteName            = NamingUtil.GetOverrideStringValue(projectInfo, "SiteName", "Default");
                    siteLongName        = NamingUtil.GetLongNameOverride(projectInfo, NamingUtil.GetOverrideStringValue(projectInfo, "SiteLongName", null));
                    siteLandTitleNumber = NamingUtil.GetOverrideStringValue(projectInfo, "SiteLandTitleNumber", null);

                    // don't bother if we have nothing in the site whatsoever.
                    if ((latitude.Count == 0 || longitude.Count == 0) && IFCAnyHandleUtil.IsNullOrHasNoValue(relativePlacement) &&
                        string.IsNullOrWhiteSpace(siteLongName) && string.IsNullOrWhiteSpace(siteLandTitleNumber))
                    {
                        return;
                    }
                }

                if (exportSite)
                {
                    siteHandle = IFCInstanceExporter.CreateSite(file, siteGUID, ownerHistory, siteName, siteDescription, siteObjectType, localPlacement,
                                                                siteRepresentation, siteLongName, Toolkit.IFCElementComposition.Element, latitude, longitude, elevation, siteLandTitleNumber, null);
                    productWrapper.AddSite(mainSiteElement, siteHandle);
                    ExporterCacheManager.SiteHandle = siteHandle;
                }


                tr.Commit();
            }
        }
Esempio n. 14
0
 /// <summary>
 /// Exports IFC site object if having latitude and longitude.
 /// </summary>
 /// <param name="exporterIFC">
 /// The ExporterIFC object.
 /// </param>
 /// <param name="document">
 /// The Revit document.
 /// </param>
 /// <param name="productWrapper">
 /// The ProductWrapper.
 /// </param>
 public static void ExportDefaultSite(ExporterIFC exporterIFC, Document document, ProductWrapper productWrapper)
 {
     ExportSiteBase(exporterIFC, document, null, null, productWrapper);
 }
Esempio n. 15
0
 public IActionResult SellProducts([FromBody] List <Product> products)
 {
     _lastTransaction = _transactionRepository.AddTransaction(ProductWrapper.productHistories(products), TransactionType.Sold);
     _productRepository.RemoveOrUpdateProducts(products);
     return(Ok());
 }
        /// <summary>
        /// Exports a curtain system to IFC curtain system.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="hostElement">The curtain system element to be exported.</param>
        /// <param name="productWrapper">The ProductWrapper.</param>
        public static void ExportCurtainSystem(ExporterIFC exporterIFC, CurtainSystem curtainSystem, ProductWrapper productWrapper)
        {
            // Check the intended IFC entity or type name is in the exclude list specified in the UI
            Common.Enums.IFCEntityType elementClassTypeEnum = Common.Enums.IFCEntityType.IfcCurtainWall;
            if (ExporterCacheManager.ExportOptionsCache.IsElementInExcludeList(elementClassTypeEnum))
            {
                return;
            }

            IFCFile file = exporterIFC.GetFile();

            using (IFCTransaction transaction = new IFCTransaction(file))
            {
                ExportBaseWithGrids(exporterIFC, curtainSystem, productWrapper);
                transaction.Commit();
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Exports text note elements.
        /// </summary>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="textNote">
        /// The text note element.
        /// </param>
        /// <param name="productWrapper">
        /// The ProductWrapper.
        /// </param>
        public static void Export(ExporterIFC exporterIFC, TextNote textNote, ProductWrapper productWrapper)
        {
            // Entity not allowed in IFC4RV
            if (ExporterCacheManager.ExportOptionsCache.ExportAs4ReferenceView)
            {
                return;
            }

            // Check the intended IFC entity or type name is in the exclude list specified in the UI
            Common.Enums.IFCEntityType elementClassTypeEnum;
            if (Enum.TryParse <Common.Enums.IFCEntityType>("IfcAnnotation", out elementClassTypeEnum))
            {
                if (ExporterCacheManager.ExportOptionsCache.IsElementInExcludeList(elementClassTypeEnum))
                {
                    return;
                }
            }

            IFCFile file = exporterIFC.GetFile();

            using (IFCTransaction tr = new IFCTransaction(file))
            {
                string textString = textNote.Text;
                if (String.IsNullOrEmpty(textString))
                {
                    throw new Exception("TextNote does not have test string.");
                }

                ElementId symId = textNote.GetTypeId();
                if (symId == ElementId.InvalidElementId)
                {
                    throw new Exception("TextNote does not have valid type id.");
                }

                PresentationStyleAssignmentCache cache = ExporterCacheManager.PresentationStyleAssignmentCache;
                IFCAnyHandle presHnd = cache.Find(symId);
                if (IFCAnyHandleUtil.IsNullOrHasNoValue(presHnd))
                {
                    TextElementType textElemType = textNote.Symbol;
                    CreatePresentationStyleAssignmentForTextElementType(exporterIFC, textElemType, cache);
                    presHnd = cache.Find(symId);
                    if (IFCAnyHandleUtil.IsNullOrHasNoValue(presHnd))
                    {
                        throw new Exception("Failed to create presentation style assignment for TextElementType.");
                    }
                }

                HashSet <IFCAnyHandle> presHndSet = new HashSet <IFCAnyHandle>();
                presHndSet.Add(presHnd);

                using (PlacementSetter setter = PlacementSetter.Create(exporterIFC, textNote))
                {
                    const double planScale = 100.0; // currently hardwired.

                    XYZ orig = UnitUtil.ScaleLength(textNote.Coord);
                    XYZ yDir = textNote.UpDirection;
                    XYZ xDir = textNote.BaseDirection;
                    XYZ zDir = xDir.CrossProduct(yDir);

                    double sizeX = UnitUtil.ScaleLength(textNote.Width * planScale);
                    double sizeY = UnitUtil.ScaleLength(textNote.Height * planScale);

                    // When we display text on screen, we "flip" it if the xDir is negative with relation to
                    // the X-axis.  So if it is, we'll flip x and y.
                    bool flipOrig = false;
                    if (xDir.X < 0)
                    {
                        xDir     = xDir.Multiply(-1.0);
                        yDir     = yDir.Multiply(-1.0);
                        flipOrig = true;
                    }

                    // xFactor, yFactor only used if flipOrig.
                    double xFactor = 0.0, yFactor = 0.0;
                    string boxAlignment = ConvertTextNoteAlignToBoxAlign(textNote, out xFactor, out yFactor);

                    // modify the origin to match the alignment.  In Revit, the origin is at the top-left (unless flipped,
                    // then bottom-right).
                    if (flipOrig)
                    {
                        orig = orig.Add(xDir.Multiply(sizeX * xFactor));
                        orig = orig.Add(yDir.Multiply(sizeY * yFactor));
                    }

                    IFCAnyHandle origin = ExporterUtil.CreateAxis(file, orig, zDir, xDir);

                    IFCAnyHandle extent         = IFCInstanceExporter.CreatePlanarExtent(file, sizeX, sizeY);
                    IFCAnyHandle repItemHnd     = IFCInstanceExporter.CreateTextLiteralWithExtent(file, textString, origin, Toolkit.IFCTextPath.Left, extent, boxAlignment);
                    IFCAnyHandle annoTextOccHnd = IFCInstanceExporter.CreateStyledItem(file, repItemHnd, presHndSet, null);

                    ElementId catId = textNote.Category != null ? textNote.Category.Id : ElementId.InvalidElementId;
                    HashSet <IFCAnyHandle> bodyItems = new HashSet <IFCAnyHandle>();
                    bodyItems.Add(repItemHnd);
                    IFCAnyHandle bodyRepHnd = RepresentationUtil.CreateAnnotationSetRep(exporterIFC, textNote, catId, exporterIFC.Get2DContextHandle(), bodyItems);

                    if (IFCAnyHandleUtil.IsNullOrHasNoValue(bodyRepHnd))
                    {
                        throw new Exception("Failed to create shape representation.");
                    }

                    IList <IFCAnyHandle> shapeReps = new List <IFCAnyHandle>();
                    shapeReps.Add(bodyRepHnd);

                    IFCAnyHandle prodShapeHnd = IFCInstanceExporter.CreateProductDefinitionShape(file, null, null, shapeReps);
                    IFCAnyHandle annoHnd      = IFCInstanceExporter.CreateAnnotation(exporterIFC, textNote, GUIDUtil.CreateGUID(), ExporterCacheManager.OwnerHistoryHandle,
                                                                                     setter.LocalPlacement, prodShapeHnd);

                    productWrapper.AddAnnotation(annoHnd, setter.LevelInfo, true);
                }

                tr.Commit();
            }
        }
        /// <summary>
        /// Exports a legacy curtain element to IFC curtain wall.
        /// </summary>
        /// <param name="exporterIFC">The exporter.</param>
        /// <param name="curtainElement">The curtain element.</param>
        /// <param name="productWrapper">The ProductWrapper.</param>
        public static void ExportLegacyCurtainElement(ExporterIFC exporterIFC, Element curtainElement, ProductWrapper productWrapper)
        {
            // Check the intended IFC entity or type name is in the exclude list specified in the UI
            Common.Enums.IFCEntityType elementClassTypeEnum = Common.Enums.IFCEntityType.IfcCurtainWall;
            if (ExporterCacheManager.ExportOptionsCache.IsElementInExcludeList(elementClassTypeEnum))
            {
                return;
            }

            ICollection <ElementId> allSubElements = ExporterIFCUtils.GetLegacyCurtainSubElements(curtainElement);

            IFCFile file = exporterIFC.GetFile();

            using (IFCTransaction transaction = new IFCTransaction(file))
            {
                ExportBase(exporterIFC, allSubElements, curtainElement, productWrapper);
                transaction.Commit();
            }
        }
Esempio n. 19
0
        /// <summary>
        ///  Exports a roof as a container of multiple roof slabs.  Returns the handle, if successful.
        /// </summary>
        /// <param name="exporterIFC">The exporter.</param>
        /// <param name="ifcEnumType">The roof type.</param>
        /// <param name="element">The roof element.</param>
        /// <param name="geometry">The geometry of the element.</param>
        /// <param name="productWrapper">The product wrapper.</param>
        /// <returns>The roof handle.</returns>
        public static IFCAnyHandle ExportRoofAsContainer(ExporterIFC exporterIFC, string ifcEnumType, Element element, GeometryElement geometry, ProductWrapper productWrapper)
        {
            IFCFile file = exporterIFC.GetFile();

            if (!(element is ExtrusionRoof) && !(element is FootPrintRoof))
            {
                return(null);
            }

            using (IFCTransaction transaction = new IFCTransaction(file))
            {
                using (PlacementSetter setter = PlacementSetter.Create(exporterIFC, element))
                {
                    IFCAnyHandle   localPlacement = setter.LocalPlacement;
                    RoofComponents roofComponents = null;
                    try
                    {
                        roofComponents = ExporterIFCUtils.GetRoofComponents(exporterIFC, element as RoofBase);
                    }
                    catch
                    {
                        return(null);
                    }

                    if (roofComponents == null)
                    {
                        return(null);
                    }

                    try
                    {
                        using (IFCExtrusionCreationData extrusionCreationData = new IFCExtrusionCreationData())
                        {
                            IFCAnyHandle ownerHistory = ExporterCacheManager.OwnerHistoryHandle;
                            extrusionCreationData.SetLocalPlacement(localPlacement);
                            extrusionCreationData.ReuseLocalPlacement = true;

                            using (TransformSetter trfSetter = TransformSetter.Create())
                            {
                                IList <GeometryObject> geometryList = new List <GeometryObject>();
                                geometryList.Add(geometry);
                                trfSetter.InitializeFromBoundingBox(exporterIFC, geometryList, extrusionCreationData);

                                IFCAnyHandle prodRepHnd = null;

                                string elementGUID        = GUIDUtil.CreateGUID(element);
                                string elementName        = NamingUtil.GetIFCName(element);
                                string elementDescription = NamingUtil.GetDescriptionOverride(element, null);
                                string elementObjectType  = NamingUtil.GetObjectTypeOverride(element, exporterIFC.GetFamilyName());
                                string elementId          = NamingUtil.CreateIFCElementId(element);
                                string roofType           = IFCValidateEntry.GetValidIFCType(element, ifcEnumType);

                                IFCAnyHandle roofHandle = IFCInstanceExporter.CreateRoof(file, elementGUID, ownerHistory, elementName, elementDescription,
                                                                                         elementObjectType, localPlacement, prodRepHnd, elementId, roofType);

                                IList <IFCAnyHandle> elementHandles = new List <IFCAnyHandle>();
                                elementHandles.Add(roofHandle);

                                // The profile curve loop is taken from the bottom face of the roof
                                XYZ extrusionDir = new XYZ(0, 0, 1);

                                ElementId catId = CategoryUtil.GetSafeCategoryId(element);

                                IList <CurveLoop> roofCurveloops = roofComponents.GetCurveLoops();
                                IList <XYZ>       planeDirs      = roofComponents.GetPlaneDirections();
                                IList <XYZ>       planeOrigins   = roofComponents.GetPlaneOrigins();
                                IList <Face>      loopFaces      = roofComponents.GetLoopFaces();
                                double            scaledDepth    = roofComponents.ScaledDepth;
                                IList <double>    areas          = roofComponents.GetAreasOfCurveLoops();

                                IList <IFCAnyHandle> slabHandles = new List <IFCAnyHandle>();
                                using (IFCExtrusionCreationData slabExtrusionCreationData = new IFCExtrusionCreationData())
                                {
                                    slabExtrusionCreationData.SetLocalPlacement(extrusionCreationData.GetLocalPlacement());
                                    slabExtrusionCreationData.ReuseLocalPlacement = false;
                                    slabExtrusionCreationData.ForceOffset         = true;

                                    for (int numLoop = 0; numLoop < roofCurveloops.Count; numLoop++)
                                    {
                                        trfSetter.InitializeFromBoundingBox(exporterIFC, geometryList, slabExtrusionCreationData);
                                        Plane             plane      = new Plane(planeDirs[numLoop], planeOrigins[numLoop]);
                                        IList <CurveLoop> curveLoops = new List <CurveLoop>();
                                        curveLoops.Add(roofCurveloops[numLoop]);
                                        double       slope = Math.Abs(planeDirs[numLoop].Z);
                                        double       scaledExtrusionDepth = scaledDepth * slope;
                                        IFCAnyHandle shapeRep             = ExtrusionExporter.CreateExtrudedSolidFromCurveLoop(exporterIFC, null, curveLoops, plane, extrusionDir, scaledExtrusionDepth);
                                        if (IFCAnyHandleUtil.IsNullOrHasNoValue(shapeRep))
                                        {
                                            return(null);
                                        }

                                        ElementId matId = HostObjectExporter.GetFirstLayerMaterialId(element as HostObject);
                                        BodyExporter.CreateSurfaceStyleForRepItem(exporterIFC, element.Document, shapeRep, matId);

                                        HashSet <IFCAnyHandle> bodyItems = new HashSet <IFCAnyHandle>();
                                        bodyItems.Add(shapeRep);
                                        shapeRep = RepresentationUtil.CreateSweptSolidRep(exporterIFC, element, catId, exporterIFC.Get3DContextHandle("Body"), bodyItems, null);
                                        IList <IFCAnyHandle> shapeReps = new List <IFCAnyHandle>();
                                        shapeReps.Add(shapeRep);

                                        IFCAnyHandle repHnd = IFCInstanceExporter.CreateProductDefinitionShape(file, null, null, shapeReps);

                                        // Allow support for up to 256 named IfcSlab components, as defined in IFCSubElementEnums.cs.
                                        string slabGUID = (numLoop < 256) ? GUIDUtil.CreateSubElementGUID(element, (int)IFCRoofSubElements.RoofSlabStart + numLoop) : GUIDUtil.CreateGUID();

                                        IFCAnyHandle slabPlacement = ExporterUtil.CreateLocalPlacement(file, slabExtrusionCreationData.GetLocalPlacement(), null);
                                        IFCAnyHandle slabHnd       = IFCInstanceExporter.CreateSlab(file, slabGUID, ownerHistory, elementName,
                                                                                                    elementDescription, elementObjectType, slabPlacement, repHnd, elementId, "ROOF");

                                        //slab quantities
                                        slabExtrusionCreationData.ScaledLength         = scaledExtrusionDepth;
                                        slabExtrusionCreationData.ScaledArea           = UnitUtil.ScaleArea(areas[numLoop]);
                                        slabExtrusionCreationData.ScaledOuterPerimeter = UnitUtil.ScaleLength(curveLoops[0].GetExactLength());
                                        slabExtrusionCreationData.Slope = UnitUtil.ScaleAngle(MathUtil.SafeAcos(Math.Abs(planeDirs[numLoop].Z)));

                                        productWrapper.AddElement(null, slabHnd, setter, slabExtrusionCreationData, false);
                                        elementHandles.Add(slabHnd);
                                        slabHandles.Add(slabHnd);
                                    }
                                }

                                productWrapper.AddElement(element, roofHandle, setter, extrusionCreationData, true);

                                ExporterUtil.RelateObjects(exporterIFC, null, roofHandle, slabHandles);

                                OpeningUtil.AddOpeningsToElement(exporterIFC, elementHandles, roofCurveloops, element, null, roofComponents.ScaledDepth,
                                                                 null, setter, localPlacement, productWrapper);

                                transaction.Commit();
                                return(roofHandle);
                            }
                        }
                    }
                    finally
                    {
                        exporterIFC.ClearFaceWithElementHandleMap();
                    }
                }
            }
        }
Esempio n. 20
0
        /// <summary>
        /// Exports a footing to IFC footing.
        /// </summary>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="footing">
        /// The footing element.
        /// </param>
        /// <param name="geometryElement">
        /// The geometry element.
        /// </param>
        /// <param name="productWrapper">
        /// The ProductWrapper.
        /// </param>
        public static void ExportFootingElement(ExporterIFC exporterIFC,
                                                WallFoundation footing, GeometryElement geometryElement, ProductWrapper productWrapper)
        {
            String ifcEnumType = "STRIP_FOOTING";

            ExportFooting(exporterIFC, footing, geometryElement, ifcEnumType, productWrapper);
        }
Esempio n. 21
0
        /// <summary>
        /// Exports a roof to IfcRoof.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="ifcEnumType">The roof type.</param>
        /// <param name="roof">The roof element.</param>
        /// <param name="geometryElement">The geometry element.</param>
        /// <param name="productWrapper">The ProductWrapper.</param>
        public static void ExportRoof(ExporterIFC exporterIFC, string ifcEnumType, Element roof, GeometryElement geometryElement,
                                      ProductWrapper productWrapper)
        {
            if (roof == null || geometryElement == null)
            {
                return;
            }

            IFCFile file = exporterIFC.GetFile();

            using (IFCTransaction tr = new IFCTransaction(file))
            {
                using (PlacementSetter placementSetter = PlacementSetter.Create(exporterIFC, roof))
                {
                    using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
                    {
                        // If the roof is an in-place family, we will allow any arbitrary orientation.  While this may result in some
                        // in-place "cubes" exporting with the wrong direction, it is unlikely that an in-place family would be
                        // used for this reason in the first place.
                        ecData.PossibleExtrusionAxes   = (roof is FamilyInstance) ? IFCExtrusionAxes.TryXYZ : IFCExtrusionAxes.TryZ;
                        ecData.AreInnerRegionsOpenings = true;
                        ecData.SetLocalPlacement(placementSetter.LocalPlacement);

                        ElementId categoryId = CategoryUtil.GetSafeCategoryId(roof);

                        BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true, ExportOptionsCache.ExportTessellationLevel.ExtraLow);
                        BodyData            bodyData;
                        IFCAnyHandle        representation = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC, roof,
                                                                                                                        categoryId, geometryElement, bodyExporterOptions, null, ecData, out bodyData);

                        if (IFCAnyHandleUtil.IsNullOrHasNoValue(representation))
                        {
                            ecData.ClearOpenings();
                            return;
                        }

                        bool exportSlab = ecData.ScaledLength > MathUtil.Eps();

                        string       guid            = GUIDUtil.CreateGUID(roof);
                        IFCAnyHandle ownerHistory    = ExporterCacheManager.OwnerHistoryHandle;
                        string       roofName        = NamingUtil.GetNameOverride(roof, NamingUtil.GetIFCName(roof));
                        string       roofDescription = NamingUtil.GetDescriptionOverride(roof, null);
                        string       roofObjectType  = NamingUtil.GetObjectTypeOverride(roof, NamingUtil.CreateIFCObjectName(exporterIFC, roof));
                        IFCAnyHandle localPlacement  = ecData.GetLocalPlacement();
                        string       elementTag      = NamingUtil.GetTagOverride(roof, NamingUtil.CreateIFCElementId(roof));
                        string       roofType        = GetIFCRoofType(ifcEnumType);
                        roofType = IFCValidateEntry.GetValidIFCType(roof, ifcEnumType);

                        IFCAnyHandle roofHnd = IFCInstanceExporter.CreateRoof(file, guid, ownerHistory, roofName, roofDescription,
                                                                              roofObjectType, localPlacement, exportSlab ? null : representation, elementTag, roofType);

                        productWrapper.AddElement(roof, roofHnd, placementSetter.LevelInfo, ecData, true);

                        // will export its host object materials later if it is a roof
                        if (!(roof is RoofBase))
                        {
                            CategoryUtil.CreateMaterialAssociations(exporterIFC, roofHnd, bodyData.MaterialIds);
                        }

                        if (exportSlab)
                        {
                            string       slabGUID = GUIDUtil.CreateSubElementGUID(roof, (int)IFCRoofSubElements.RoofSlabStart);
                            string       slabName = roofName + ":1";
                            IFCAnyHandle slabLocalPlacementHnd = ExporterUtil.CopyLocalPlacement(file, localPlacement);

                            IFCAnyHandle slabHnd = IFCInstanceExporter.CreateSlab(file, slabGUID, ownerHistory, slabName,
                                                                                  roofDescription, roofObjectType, slabLocalPlacementHnd, representation, elementTag, "ROOF");

                            Transform offsetTransform = (bodyData != null) ? bodyData.OffsetTransform : Transform.Identity;
                            OpeningUtil.CreateOpeningsIfNecessary(slabHnd, roof, ecData, offsetTransform,
                                                                  exporterIFC, slabLocalPlacementHnd, placementSetter, productWrapper);

                            ExporterUtil.RelateObject(exporterIFC, roofHnd, slabHnd);

                            productWrapper.AddElement(null, slabHnd, placementSetter.LevelInfo, ecData, false);
                            CategoryUtil.CreateMaterialAssociations(exporterIFC, slabHnd, bodyData.MaterialIds);
                        }
                    }
                    tr.Commit();
                }
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Exports an element to IFC footing.
        /// </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 ExportFooting(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;
            }

            // Check the intended IFC entity or type name is in the exclude list specified in the UI
            Common.Enums.IFCEntityType elementClassTypeEnum;
            if (Enum.TryParse <Common.Enums.IFCEntityType>("IfcFooting", out elementClassTypeEnum))
            {
                if (ExporterCacheManager.ExportOptionsCache.IsElementInExcludeList(elementClassTypeEnum))
                {
                    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);
                            prodRep = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC,
                                                                                                 element, catId, geometryElement, bodyExporterOptions, null, ecData, true);
                            if (IFCAnyHandleUtil.IsNullOrHasNoValue(prodRep))
                            {
                                ecData.ClearOpenings();
                                return;
                            }
                        }

                        string instanceGUID        = GUIDUtil.CreateGUID(element);
                        string instanceName        = NamingUtil.GetNameOverride(element, NamingUtil.GetIFCName(element));
                        string instanceDescription = NamingUtil.GetDescriptionOverride(element, null);
                        string instanceObjectType  = NamingUtil.GetObjectTypeOverride(element, exporterIFC.GetFamilyName());
                        string instanceTag         = NamingUtil.GetTagOverride(element, NamingUtil.CreateIFCElementId(element));
                        string footingType         = GetIFCFootingType(ifcEnumType); // need to keep it for legacy support when original data follows slightly diff naming
                        footingType = IFCValidateEntry.GetValidIFCType(element, footingType);

                        IFCAnyHandle footing = IFCInstanceExporter.CreateFooting(file, instanceGUID, ExporterCacheManager.OwnerHistoryHandle,
                                                                                 instanceName, instanceDescription, instanceObjectType, ecData.GetLocalPlacement(), prodRep, instanceTag, footingType);

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

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

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

                tr.Commit();
            }
        }
Esempio n. 23
0
        /// <summary>
        /// Exports a gutter element.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="element">The element.</param>
        /// <param name="geometryElement">The geometry element.</param>
        /// <param name="productWrapper">The ProductWrapper.</param>
        public static void ExportGutter(ExporterIFC exporterIFC, Element element, GeometryElement geometryElement, ProductWrapper productWrapper)
        {
            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);

                        ElementId categoryId = CategoryUtil.GetSafeCategoryId(element);

                        BodyExporterOptions bodyExporterOptions = new BodyExporterOptions();
                        IFCAnyHandle        bodyRep             = BodyExporter.ExportBody(exporterIFC, element, categoryId, ElementId.InvalidElementId,
                                                                                          geometryElement, bodyExporterOptions, ecData).RepresentationHnd;
                        if (IFCAnyHandleUtil.IsNullOrHasNoValue(bodyRep))
                        {
                            if (ecData != null)
                            {
                                ecData.ClearOpenings();
                            }
                            return;
                        }

                        IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
                        string       originalTag  = NamingUtil.CreateIFCElementId(element);

                        // In Revit, we don't have a corresponding type, so we create one for every gutter.
                        IFCAnyHandle        origin      = ExporterUtil.CreateAxis2Placement3D(file);
                        IFCAnyHandle        repMap3dHnd = IFCInstanceExporter.CreateRepresentationMap(file, origin, bodyRep);
                        List <IFCAnyHandle> repMapList  = new List <IFCAnyHandle>();
                        repMapList.Add(repMap3dHnd);
                        string elementTypeName = NamingUtil.CreateIFCObjectName(exporterIFC, element);

                        string       typeGuid = GUIDUtil.CreateSubElementGUID(element, (int)IFCHostedSweepSubElements.PipeSegmentType);
                        IFCAnyHandle style    = IFCInstanceExporter.CreatePipeSegmentType(file, typeGuid, ownerHistory,
                                                                                          elementTypeName, null, null, null, repMapList, originalTag,
                                                                                          elementTypeName, IFCPipeSegmentType.Gutter);

                        List <IFCAnyHandle> representationMaps = GeometryUtil.GetRepresentationMaps(style);
                        IFCAnyHandle        mappedItem         = ExporterUtil.CreateDefaultMappedItem(file, representationMaps[0]);

                        ISet <IFCAnyHandle> representations = new HashSet <IFCAnyHandle>();
                        representations.Add(mappedItem);

                        IFCAnyHandle bodyMappedItemRep = RepresentationUtil.CreateBodyMappedItemRep(exporterIFC,
                                                                                                    element, categoryId, exporterIFC.Get3DContextHandle("Body"), representations);
                        if (IFCAnyHandleUtil.IsNullOrHasNoValue(bodyMappedItemRep))
                        {
                            return;
                        }

                        List <IFCAnyHandle> shapeReps = new List <IFCAnyHandle>();
                        shapeReps.Add(bodyMappedItemRep);

                        IFCAnyHandle boundingBoxRep = BoundingBoxExporter.ExportBoundingBox(exporterIFC, geometryElement, Transform.Identity);
                        if (boundingBoxRep != null)
                        {
                            shapeReps.Add(boundingBoxRep);
                        }

                        IFCAnyHandle prodRep = IFCInstanceExporter.CreateProductDefinitionShape(file, null, null, shapeReps);
                        IFCAnyHandle localPlacementToUse;
                        ElementId    roomId = setter.UpdateRoomRelativeCoordinates(element, out localPlacementToUse);
                        if (roomId == ElementId.InvalidElementId)
                        {
                            localPlacementToUse = ecData.GetLocalPlacement();
                        }

                        string guid        = GUIDUtil.CreateGUID(element);
                        string name        = NamingUtil.GetNameOverride(element, NamingUtil.GetIFCName(element));
                        string description = NamingUtil.GetDescriptionOverride(element, null);
                        string objectType  = NamingUtil.GetObjectTypeOverride(element, elementTypeName);
                        string tag         = NamingUtil.GetTagOverride(element, originalTag);

                        IFCAnyHandle elemHnd = IFCInstanceExporter.CreateFlowSegment(file, guid,
                                                                                     ownerHistory, name, description, objectType, localPlacementToUse, prodRep, tag);

                        bool containedInSpace = (roomId != ElementId.InvalidElementId);
                        productWrapper.AddElement(element, elemHnd, setter.LevelInfo, ecData, !containedInSpace);

                        if (containedInSpace)
                        {
                            ExporterCacheManager.SpaceInfoCache.RelateToSpace(roomId, elemHnd);
                        }

                        // Associate segment with type.
                        ExporterCacheManager.TypeRelationsCache.Add(style, elemHnd);

                        OpeningUtil.CreateOpeningsIfNecessary(elemHnd, element, ecData, null,
                                                              exporterIFC, localPlacementToUse, setter, productWrapper);
                    }

                    tr.Commit();
                }
            }
        }
Esempio n. 24
0
        /// <summary>
        /// Exports a ramp to IfcRamp.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="element">The ramp element.</param>
        /// <param name="geometryElement">The geometry element.</param>
        /// <param name="productWrapper">The ProductWrapper.</param>
        public static void Export(ExporterIFC exporterIFC, Element element, GeometryElement geometryElement, ProductWrapper productWrapper)
        {
            string  ifcEnumType = ExporterUtil.GetIFCTypeFromExportTable(exporterIFC, element);
            IFCFile file        = exporterIFC.GetFile();

            using (IFCTransaction tr = new IFCTransaction(file))
            {
                if (!(element is FamilyInstance))
                {
                    StairsExporter.ExportLegacyStairOrRampAsContainer(exporterIFC, ifcEnumType, element, geometryElement, productWrapper);
                    if (IFCAnyHandleUtil.IsNullOrHasNoValue(productWrapper.GetAnElement()))
                    {
                        int numFlights = GetNumFlightsForRamp(exporterIFC, element);
                        if (numFlights > 0)
                        {
                            ExportRamp(exporterIFC, ifcEnumType, element, geometryElement, numFlights, productWrapper);
                        }
                    }
                }
                else
                {
                    ExportRamp(exporterIFC, ifcEnumType, element, geometryElement, 1, productWrapper);
                }

                tr.Commit();
            }
        }