/// <summary> /// Collect information to create zones and cache them to create when end export. /// </summary> /// <param name="exporterIFC"> /// The exporterIFC object. /// </param> /// <param name="file"> /// The IFCFile object. /// </param> /// <param name="element"> /// The element. /// </param> /// <param name="productWrapper"> /// The ProductWrapper. /// </param> static void CreateZoneInfos(ExporterIFC exporterIFC, IFCFile file, Element element, ProductWrapper productWrapper) { bool exportToCOBIE = ExporterCacheManager.ExportOptionsCache.FileVersion == IFCVersion.IFCCOBIE; // Zone Information - For BCA / GSA int val = 0; string basePropZoneName = "ZoneName"; string basePropZoneObjectType = "ZoneObjectType"; string basePropZoneDescription = "ZoneDescription"; // While a room may contain multiple zones, only one can have the extra GSA parameters. We will allow the first zone encountered // to be defined by them. If we require defining multiple zones in one room, then the code below should be modified to modify the // names of the shared parameters to include the index of the appropriate room. bool exportedExtraZoneInformation = false; while (++val < 1000) // prevent infinite loop. { string propZoneName, propZoneObjectType, propZoneDescription; if (val == 1) { propZoneName = basePropZoneName; propZoneObjectType = basePropZoneObjectType; propZoneDescription = basePropZoneDescription; } else { propZoneName = basePropZoneName + " " + val; propZoneObjectType = basePropZoneObjectType + " " + val; propZoneDescription = basePropZoneDescription + " " + val; } { string zoneName; string zoneObjectType; string zoneDescription; if (ParameterUtil.GetStringValueFromElementOrSymbol(element, propZoneName, out zoneName) && !String.IsNullOrEmpty(zoneName)) { ParameterUtil.GetStringValueFromElementOrSymbol(element, propZoneObjectType, out zoneObjectType); ParameterUtil.GetStringValueFromElementOrSymbol(element, propZoneDescription, out zoneDescription); IFCAnyHandle roomHandle = productWrapper.GetElementOfType(IFCEntityType.IfcSpace); Dictionary<string, IFCAnyHandle> classificationHandles = new Dictionary<string, IFCAnyHandle>(); IFCAnyHandle energyAnalysisPSetHnd = null; if (exportToCOBIE && !exportedExtraZoneInformation) { bool isSpatialZone = NamingUtil.IsEqualIgnoringCaseAndSpaces(zoneObjectType, "SpatialZone"); if (isSpatialZone) { // Classifications. Document doc = element.Document; ProjectInfo projectInfo = doc.ProjectInformation; string location; ParameterUtil.GetStringValueFromElement(projectInfo, "BIM Standards URL", out location); string itemReference; string itemName; // Spatial Zone Type (Owner) if (ParameterUtil.GetStringValueFromElementOrSymbol(element, "Spatial Zone Type (Owner) Reference", out itemReference)) { ParameterUtil.GetStringValueFromElementOrSymbol(element, "Spatial Zone Type (Owner) Name", out itemName); IFCAnyHandle classificationReference = IFCInstanceExporter.CreateClassificationReference(file, location, itemReference, itemName, null); classificationHandles["Spatial Zone Type (Owner)"] = classificationReference; } // Spatial Zone Security Level (Owner) if (ParameterUtil.GetStringValueFromElementOrSymbol(element, "Spatial Zone Security Level (Owner) Reference", out itemReference)) { itemName = ""; ParameterUtil.GetStringValueFromElementOrSymbol(element, "Spatial Zone Security Level (Owner) Name", out itemName); IFCAnyHandle classificationReference = IFCInstanceExporter.CreateClassificationReference(file, location, itemReference, itemName, null); classificationHandles["Spatial Zone Security Level (Owner)"] = classificationReference; } // Spatial Zone Type (Energy Analysis) if (ParameterUtil.GetStringValueFromElementOrSymbol(element, "ASHRAE Zone Type", out itemName)) { IFCAnyHandle classificationReference = IFCInstanceExporter.CreateClassificationReference(file, "ASHRAE 90.1", "Common Space Type", itemName, null); classificationHandles["ASHRAE Zone Type"] = classificationReference; } } if (isSpatialZone || NamingUtil.IsEqualIgnoringCaseAndSpaces(zoneObjectType, "EnergyAnalysisZone")) { // Property Sets. We don't use the generic Property Set mechanism because Zones aren't "real" elements. energyAnalysisPSetHnd = CreateSpatialZoneEnergyAnalysisPSet(exporterIFC, file, element); if (classificationHandles.Count > 0 || energyAnalysisPSetHnd != null) exportedExtraZoneInformation = true; } } ZoneInfo zoneInfo = ExporterCacheManager.ZoneInfoCache.Find(zoneName); if (zoneInfo == null) { zoneInfo = new ZoneInfo(zoneObjectType, zoneDescription, roomHandle, classificationHandles, energyAnalysisPSetHnd); ExporterCacheManager.ZoneInfoCache.Register(zoneName, zoneInfo); } else { // if description and object type were empty, overwrite. if (!String.IsNullOrEmpty(zoneObjectType) && String.IsNullOrEmpty(zoneInfo.ObjectType)) zoneInfo.ObjectType = zoneObjectType; if (!String.IsNullOrEmpty(zoneDescription) && String.IsNullOrEmpty(zoneInfo.Description)) zoneInfo.Description = zoneDescription; zoneInfo.RoomHandles.Add(roomHandle); foreach (KeyValuePair<string, IFCAnyHandle> classificationReference in classificationHandles) { if (!zoneInfo.ClassificationReferences[classificationReference.Key].HasValue) zoneInfo.ClassificationReferences[classificationReference.Key] = classificationReference.Value; else { // Delete redundant IfcClassificationReference from file. classificationReference.Value.Delete(); } } if (zoneInfo.EnergyAnalysisProperySetHandle == null || !zoneInfo.EnergyAnalysisProperySetHandle.HasValue) zoneInfo.EnergyAnalysisProperySetHandle = energyAnalysisPSetHnd; else if (energyAnalysisPSetHnd.HasValue) energyAnalysisPSetHnd.Delete(); } } else break; } } }
/// <summary> /// Collect information to create zones and cache them to create when end export. /// </summary> /// <param name="exporterIFC">The exporterIFC object.</param> /// <param name="file">The IFCFile object.</param> /// <param name="element">The element.</param> /// <param name="productWrapper">The ProductWrapper.</param> static void CreateZoneInfos(ExporterIFC exporterIFC, IFCFile file, Element element, ProductWrapper productWrapper) { bool exportToCOBIE = ExporterCacheManager.ExportOptionsCache.FileVersion == IFCVersion.IFCCOBIE; // Extra zone information, since Revit doesn't have architectural zones. int val = 0; string basePropZoneName = "ZoneName"; string basePropZoneObjectType = "ZoneObjectType"; string basePropZoneDescription = "ZoneDescription"; string basePropZoneClassificationCode = "ZoneClassificationCode"; // While a room may contain multiple zones, only one can have the extra parameters. We will allow the first zone encountered // to be defined by them. If we require defining multiple zones in one room, then the code below should be modified to modify the // names of the shared parameters to include the index of the appropriate room. bool exportedExtraZoneInformation = false; while (++val < 1000) // prevent infinite loop. { string propZoneName, propZoneObjectType, propZoneDescription, propZoneClassificationCode; if (val == 1) { propZoneName = basePropZoneName; propZoneObjectType = basePropZoneObjectType; propZoneDescription = basePropZoneDescription; propZoneClassificationCode = basePropZoneClassificationCode; } else { propZoneName = basePropZoneName + " " + val; propZoneObjectType = basePropZoneObjectType + " " + val; propZoneDescription = basePropZoneDescription + " " + val; propZoneClassificationCode = basePropZoneClassificationCode + " " + val; } string zoneName; string zoneObjectType; string zoneDescription; string zoneClassificationCode; IFCAnyHandle zoneClassificationReference; if (ParameterUtil.GetOptionalStringValueFromElementOrSymbol(element, propZoneName, out zoneName) == null) break; // If we have an empty zone name, but the value exists, keep looking to make sure there aren't valid values later. if (!String.IsNullOrEmpty(zoneName)) { Dictionary<string, IFCAnyHandle> classificationHandles = new Dictionary<string, IFCAnyHandle>(); ParameterUtil.GetStringValueFromElementOrSymbol(element, propZoneObjectType, out zoneObjectType); ParameterUtil.GetStringValueFromElementOrSymbol(element, propZoneDescription, out zoneDescription); ParameterUtil.GetStringValueFromElementOrSymbol(element, propZoneClassificationCode, out zoneClassificationCode); string classificationName, classificationCode, classificationDescription; if (!String.IsNullOrEmpty(zoneClassificationCode)) { ClassificationUtil.ParseClassificationCode(zoneClassificationCode, propZoneClassificationCode, out classificationName, out classificationCode, out classificationDescription); string location = null; ExporterCacheManager.ClassificationLocationCache.TryGetValue(classificationName, out location); zoneClassificationReference = ClassificationUtil.CreateClassificationReference(file, classificationName, classificationCode, classificationDescription, location); classificationHandles.Add(classificationName, zoneClassificationReference); } IFCAnyHandle roomHandle = productWrapper.GetElementOfType(IFCEntityType.IfcSpace); IFCAnyHandle energyAnalysisPSetHnd = null; if (exportToCOBIE && !exportedExtraZoneInformation) { exportedExtraZoneInformation = CreateGSAInformation(exporterIFC, element, zoneObjectType, classificationHandles, energyAnalysisPSetHnd); } ZoneInfo zoneInfo = ExporterCacheManager.ZoneInfoCache.Find(zoneName); if (zoneInfo == null) { IFCAnyHandle zoneCommonPropertySetHandle = CreateZoneCommonPSet(exporterIFC, file, element); zoneInfo = new ZoneInfo(zoneObjectType, zoneDescription, roomHandle, classificationHandles, energyAnalysisPSetHnd, zoneCommonPropertySetHandle); ExporterCacheManager.ZoneInfoCache.Register(zoneName, zoneInfo); } else { // if description and object type were empty, overwrite. if (!String.IsNullOrEmpty(zoneObjectType) && String.IsNullOrEmpty(zoneInfo.ObjectType)) zoneInfo.ObjectType = zoneObjectType; if (!String.IsNullOrEmpty(zoneDescription) && String.IsNullOrEmpty(zoneInfo.Description)) zoneInfo.Description = zoneDescription; zoneInfo.RoomHandles.Add(roomHandle); foreach (KeyValuePair<string, IFCAnyHandle> classificationReference in classificationHandles) { if (!zoneInfo.ClassificationReferences[classificationReference.Key].HasValue) zoneInfo.ClassificationReferences[classificationReference.Key] = classificationReference.Value; else { // Delete redundant IfcClassificationReference from file. classificationReference.Value.Delete(); } } if (IFCAnyHandleUtil.IsNullOrHasNoValue(zoneInfo.EnergyAnalysisProperySetHandle)) zoneInfo.EnergyAnalysisProperySetHandle = energyAnalysisPSetHnd; else if (energyAnalysisPSetHnd.HasValue) energyAnalysisPSetHnd.Delete(); if (IFCAnyHandleUtil.IsNullOrHasNoValue(zoneInfo.ZoneCommonProperySetHandle)) zoneInfo.ZoneCommonProperySetHandle = CreateZoneCommonPSet(exporterIFC, file, element); } } } }