public static void TryToCreateMaterialAssocation(ExporterIFC exporterIFC, BodyData bodyData, Element elementType, Element element, GeometryElement exportGeometry, IFCAnyHandle typeStyle, FamilyTypeInfo typeInfo) { if (bodyData != null && bodyData.RepresentationItemInfo != null && bodyData.RepresentationItemInfo.Count > 0) { CreateMaterialAssociationWithShapeAspect(exporterIFC, elementType, typeStyle, bodyData.RepresentationItemInfo); return; } bool addedMaterialAssociation = false; IList <ElementId> matIds = BodyExporter.GetMaterialIdsFromGeometryOrParameters(exportGeometry, elementType, element); if (matIds.Count > 0) { CreateMaterialAssociation(exporterIFC, typeStyle, matIds); addedMaterialAssociation = true; if (typeInfo.MaterialIdList.Count == 0) { typeInfo.MaterialIdList = matIds; } } if (!addedMaterialAssociation) { CreateMaterialAssociation(exporterIFC, typeStyle, typeInfo.MaterialIdList); } return; }
/// <summary> /// Adds the FamilyTypeInfo to the dictionary. /// </summary> /// <param name="elementId"> /// The element elementId. /// </param> /// <param name="flipped"> /// Indicates if the element is flipped. /// </param> /// <param name="exportType"> /// The export type of the element. /// </param> public void Register(ElementId elementId, bool flipped, IFCExportType exportType, FamilyTypeInfo typeInfo) { Tuple <ElementId, bool, IFCExportType> key = new Tuple <ElementId, bool, IFCExportType>(elementId, flipped, exportType); this[key] = typeInfo; }
/// <summary> /// Creates the shared beam and column QTO values. /// </summary> /// <remarks> /// This code uses the native implementation for creating these quantities, and the native class for storing the information. /// This will be obsoleted. /// </remarks> /// <param name="exporterIFC">The exporter.</param> /// <param name="elemHandle">The element handle.</param> /// <param name="element">The beam or column element.</param> /// <param name="typeInfo">The FamilyTypeInfo containing the appropriate data.</param> public static void CreateBeamColumnBaseQuantities(ExporterIFC exporterIFC, IFCAnyHandle elemHandle, Element element, FamilyTypeInfo typeInfo) { IFCTypeInfo ifcTypeInfo = new IFCTypeInfo(); ifcTypeInfo.ScaledDepth = typeInfo.ScaledDepth; ifcTypeInfo.ScaledArea = typeInfo.ScaledArea; ifcTypeInfo.ScaledInnerPerimeter = typeInfo.ScaledInnerPerimeter; ifcTypeInfo.ScaledOuterPerimeter = typeInfo.ScaledOuterPerimeter; ExporterIFCUtils.CreateBeamColumnBaseQuantities(exporterIFC, elemHandle, element, ifcTypeInfo); }
/// <summary> /// Adds the FamilyTypeInfo to the dictionary. /// </summary> /// <param name="elementId"> /// The element elementId. /// </param> /// <param name="flipped"> /// Indicates if the element is flipped. /// </param> public void Register(ElementId elementId, bool flipped, FamilyTypeInfo typeInfo) { KeyValuePair <ElementId, bool> key = new KeyValuePair <ElementId, bool>(elementId, flipped); this[key] = typeInfo; }
/// <summary> /// Creates the shared beam, column and member QTO values. /// </summary> /// <param name="exporterIFC">The exporter.</param> /// <param name="elemHandle">The element handle.</param> /// <param name="element">The element.</param> /// <param name="ecData">The IFCExtrusionCreationData containing the appropriate data.</param> public static void CreateBeamColumnMemberBaseQuantities(ExporterIFC exporterIFC, IFCAnyHandle elemHandle, Element element, IFCExtrusionCreationData ecData) { FamilyTypeInfo ifcTypeInfo = new FamilyTypeInfo(); ifcTypeInfo.ScaledDepth = ecData.ScaledLength; ifcTypeInfo.ScaledArea = ecData.ScaledArea; ifcTypeInfo.ScaledInnerPerimeter = ecData.ScaledInnerPerimeter; ifcTypeInfo.ScaledOuterPerimeter = ecData.ScaledOuterPerimeter; CreateBeamColumnBaseQuantities(exporterIFC, elemHandle, element, ifcTypeInfo); }
/// <summary> /// Creates the shared beam and column QTO values. /// </summary> /// <remarks> /// This code uses the native implementation for creating these quantities, and the native class for storing the information. /// This will be obsoleted. /// </remarks> /// <param name="exporterIFC">The exporter.</param> /// <param name="elemHandle">The element handle.</param> /// <param name="element">The beam or column element.</param> /// <param name="typeInfo">The FamilyTypeInfo containing the appropriate data.</param> public static void CreateBeamColumnBaseQuantities(ExporterIFC exporterIFC, IFCAnyHandle elemHandle, Element element, FamilyTypeInfo typeInfo) { // Make sure QTO export is enabled. if (!ExporterCacheManager.ExportOptionsCache.ExportBaseQuantities || (ExporterCacheManager.ExportOptionsCache.FileVersion == IFCVersion.IFCCOBIE)) return; IFCFile file = exporterIFC.GetFile(); HashSet<IFCAnyHandle> quantityHnds = new HashSet<IFCAnyHandle>(); double scaledLength = typeInfo.ScaledDepth; double scaledArea = typeInfo.ScaledArea; double crossSectionArea = scaledArea; double scaledOuterPerimeter = typeInfo.ScaledOuterPerimeter; double scaledInnerPerimeter = typeInfo.ScaledInnerPerimeter; if (scaledLength > MathUtil.Eps()) { IFCAnyHandle quantityHnd = IFCInstanceExporter.CreateQuantityLength(file, "Length", null, null, scaledLength); quantityHnds.Add(quantityHnd); } if (MathUtil.AreaIsAlmostZero(crossSectionArea)) { if (element != null) { ParameterUtil.GetDoubleValueFromElement(element, BuiltInParameter.HOST_AREA_COMPUTED, out crossSectionArea); crossSectionArea = UnitUtil.ScaleArea(crossSectionArea); } } if (!MathUtil.AreaIsAlmostZero(scaledArea)) { IFCAnyHandle quantityHnd = IFCInstanceExporter.CreateQuantityArea(file, "CrossSectionArea", null, null, crossSectionArea); quantityHnds.Add(quantityHnd); } if (!MathUtil.AreaIsAlmostZero(scaledArea) && !MathUtil.IsAlmostZero(scaledLength) && !MathUtil.IsAlmostZero(scaledOuterPerimeter)) { double scaledPerimeter = scaledOuterPerimeter + scaledInnerPerimeter; double outSurfaceArea = scaledArea * 2 + scaledLength * scaledPerimeter; IFCAnyHandle quantityHnd = IFCInstanceExporter.CreateQuantityArea(file, "OuterSurfaceArea", null, null, outSurfaceArea); quantityHnds.Add(quantityHnd); } double volume = 0.0; if (element != null) { ParameterUtil.GetDoubleValueFromElement(element, BuiltInParameter.HOST_VOLUME_COMPUTED, out volume); volume = UnitUtil.ScaleArea(volume); } if (MathUtil.VolumeIsAlmostZero(volume)) { volume = scaledLength * scaledArea; } if (!MathUtil.VolumeIsAlmostZero(volume)) { IFCAnyHandle quantityHnd = IFCInstanceExporter.CreateQuantityVolume(file, "GrossVolume", null, null, volume); quantityHnds.Add(quantityHnd); } CreateAndRelateBaseQuantities(file, exporterIFC, elemHandle, quantityHnds); }
/// <summary> /// Creates the shared beam and column QTO values. /// </summary> /// <remarks> /// This code uses the native implementation for creating these quantities, and the native class for storing the information. /// This will be obsoleted. /// </remarks> /// <param name="exporterIFC">The exporter.</param> /// <param name="elemHandle">The element handle.</param> /// <param name="element">The beam or column element.</param> /// <param name="typeInfo">The FamilyTypeInfo containing the appropriate data.</param> /// <param name="geomObjects">The list of geometries for the exported column only, used if split walls and columns is set.</param> /// <remarks>The geomObjects is used if we have the split by level option. It is intended only for columns, as beams and members are not split by level. /// In this case, we use the solids in the list to determine the real volume of the exported objects. If the list contains meshes, we won't export the volume at all.</remarks> public static void CreateBeamColumnBaseQuantities(ExporterIFC exporterIFC, IFCAnyHandle elemHandle, Element element, FamilyTypeInfo typeInfo, IList<GeometryObject> geomObjects) { // Make sure QTO export is enabled. if (!ExporterCacheManager.ExportOptionsCache.ExportBaseQuantities || (ExporterCacheManager.ExportOptionsCache.ExportAsCOBIE)) return; IFCFile file = exporterIFC.GetFile(); HashSet<IFCAnyHandle> quantityHnds = new HashSet<IFCAnyHandle>(); double scaledLength = typeInfo.ScaledDepth; double scaledArea = typeInfo.ScaledArea; double crossSectionArea = scaledArea; double scaledOuterPerimeter = typeInfo.ScaledOuterPerimeter; double scaledInnerPerimeter = typeInfo.ScaledInnerPerimeter; if (scaledLength > MathUtil.Eps()) { IFCAnyHandle quantityHnd = IFCInstanceExporter.CreateQuantityLength(file, "Length", null, null, scaledLength); quantityHnds.Add(quantityHnd); } if (MathUtil.AreaIsAlmostZero(crossSectionArea)) { if (element != null) { ParameterUtil.GetDoubleValueFromElement(element, BuiltInParameter.HOST_AREA_COMPUTED, out crossSectionArea); crossSectionArea = UnitUtil.ScaleArea(crossSectionArea); } } if (!MathUtil.AreaIsAlmostZero(scaledArea)) { IFCAnyHandle quantityHnd = IFCInstanceExporter.CreateQuantityArea(file, "CrossSectionArea", null, null, crossSectionArea); quantityHnds.Add(quantityHnd); } if (!MathUtil.AreaIsAlmostZero(scaledArea) && !MathUtil.IsAlmostZero(scaledLength) && !MathUtil.IsAlmostZero(scaledOuterPerimeter)) { double scaledPerimeter = scaledOuterPerimeter + scaledInnerPerimeter; double outSurfaceArea = scaledArea * 2 + scaledLength * scaledPerimeter; IFCAnyHandle quantityHnd = IFCInstanceExporter.CreateQuantityArea(file, "OuterSurfaceArea", null, null, outSurfaceArea); quantityHnds.Add(quantityHnd); } double volume = 0.0; if (element != null) { // If we are splitting columns, we will look at the actual geometry used when exporting this segment // of the column, but only if we have the geomObjects passed in. if (geomObjects != null && ExporterCacheManager.ExportOptionsCache.WallAndColumnSplitting) { foreach (GeometryObject geomObj in geomObjects) { // We don't suport calculating the volume of Meshes at this time. if (geomObj is Mesh) { volume = 0.0; break; } if (geomObj is Solid) volume += (geomObj as Solid).Volume; } } else ParameterUtil.GetDoubleValueFromElement(element, BuiltInParameter.HOST_VOLUME_COMPUTED, out volume); volume = UnitUtil.ScaleVolume(volume); } // If we didn't calculate the volume above, but we did pass in a non-zero scaled length and area, calculate the volume. if (MathUtil.VolumeIsAlmostZero(volume)) volume = scaledLength * scaledArea; if (!MathUtil.VolumeIsAlmostZero(volume)) { IFCAnyHandle quantityHnd = IFCInstanceExporter.CreateQuantityVolume(file, "GrossVolume", null, null, volume); quantityHnds.Add(quantityHnd); } CreateAndRelateBaseQuantities(file, exporterIFC, elemHandle, quantityHnds); }