/// <summary> /// Set few attributes for already created distribution port /// </summary> /// <param name="port">The handle of exported connector.</param> /// <param name="connector">The Connector object.</param> /// <param name="portAutoName">The auto gerated name with id.</param> /// <param name="portDescription">The description string to set.</param> private static void SetDistributionPortAttributes(IFCAnyHandle port, Connector connector, string portDescription, ElementId hostId, ref IFCFlowDirection flowDir) { // "Description" IFCAnyHandleUtil.SetAttribute(port, "Description", portDescription); // "Flow" (only for Electrical connectors) if (connector.Domain == Domain.DomainElectrical) { string flowString = ConnectorExporter.GetConnectorParameterFromDescription(connector, "Flow"); IFCFlowDirection parsedFlow; if (Enum.TryParse(flowString, true, out parsedFlow) && (parsedFlow == IFCFlowDirection.Sink || parsedFlow == IFCFlowDirection.Source)) { flowDir = parsedFlow; IFCAnyHandleUtil.SetAttribute(port, "FlowDirection", flowDir); } } // "Name" string portName = ConnectorExporter.GetConnectorParameterFromDescription(connector, "PortName"); if (String.IsNullOrEmpty(portName)) { portName = ConnectorExporter.GetPortNameFromFlowDirection(flowDir, hostId, connector.Id); } IFCAnyHandleUtil.OverrideNameAttribute(port, portName); if (ExporterCacheManager.ExportOptionsCache.ExportAs4) { // "PredefinedType" Toolkit.IFC4.IFCDistributionPortType portType = GetMappedIFCDistributionPortType(connector.Domain); string validatedPredefinedType = IFCValidateEntry.ValidateStrEnum <Toolkit.IFC4.IFCDistributionPortType>(portType.ToString()); IFCAnyHandleUtil.SetAttribute(port, "PredefinedType", validatedPredefinedType, true); // "SystemType" from description string systemTypeFromDescription = ConnectorExporter.GetConnectorParameterFromDescription(connector, "SystemType"); string validatedSystemType = IFCValidateEntry.ValidateStrEnum <Toolkit.IFC4.IFCDistributionSystem>(systemTypeFromDescription); if (String.IsNullOrEmpty(validatedSystemType)) { // "SystemType" from revit system classification Toolkit.IFC4.IFCDistributionSystem systemType = GetMappedIFCDistributionSystem(connector); validatedSystemType = IFCValidateEntry.ValidateStrEnum <Toolkit.IFC4.IFCDistributionSystem>(systemType.ToString()); } if (!String.IsNullOrEmpty(validatedSystemType)) { IFCAnyHandleUtil.SetAttribute(port, "SystemType", validatedSystemType, true); } } }
/// <summary> /// Set few attributes for already created distribution port /// </summary> /// <param name="port">The handle of exported connector.</param> /// <param name="connector">The Connector object.</param> /// <param name="portAutoName">The auto gerated name with id.</param> /// <param name="portDescription">The description string to set.</param> private static void SetDistributionPortAttributes(IFCAnyHandle port, Connector connector, string portAutoName, string portDescription) { // "Description" IFCAnyHandleUtil.SetAttribute(port, "Description", portDescription); // "Name" string portName = ConnectorExporter.GetConnectorParameterFromDescription(connector, "PortName"); if (String.IsNullOrEmpty(portName)) { portName = portAutoName; } IFCAnyHandleUtil.OverrideNameAttribute(port, portName); if (ExporterCacheManager.ExportOptionsCache.ExportAs4) { // "PredefinedType" Toolkit.IFC4.IFCDistributionPortType portType = GetMappedIFCDistributionPortType(connector.Domain); string validatedPredefinedType = IFCValidateEntry.ValidateStrEnum <Toolkit.IFC4.IFCDistributionPortType>(portType.ToString()); IFCAnyHandleUtil.SetAttribute(port, "PredefinedType", validatedPredefinedType, true); // "SystemType" from description string systemTypeFromDescription = ConnectorExporter.GetConnectorParameterFromDescription(connector, "SystemType"); string validatedSystemType = IFCValidateEntry.ValidateStrEnum <Toolkit.IFC4.IFCDistributionSystem>(systemTypeFromDescription); if (String.IsNullOrEmpty(validatedSystemType)) { // "SystemType" from revit system classification Toolkit.IFC4.IFCDistributionSystem systemType = GetMappedIFCDistributionSystem(connector); validatedSystemType = IFCValidateEntry.ValidateStrEnum <Toolkit.IFC4.IFCDistributionSystem>(systemType.ToString()); } if (!String.IsNullOrEmpty(validatedSystemType)) { IFCAnyHandleUtil.SetAttribute(port, "SystemType", validatedSystemType, true); } } }