Пример #1
0
        /// <summary>
        /// Get ifc distribution system type from connector
        /// </summary>
        /// <param name="connector">The connector.</param>
        /// <returns>ifc distribution system type.</returns>
        private static Toolkit.IFC4.IFCDistributionSystem GetMappedIFCDistributionSystem(Connector connector)
        {
            Toolkit.IFC4.IFCDistributionSystem systemType = Toolkit.IFC4.IFCDistributionSystem.NOTDEFINED;

            string systemClassificationString = "UndefinedSystemClassification";

            try
            {
                switch (connector.Domain)
                {
                case Domain.DomainHvac:
                    systemClassificationString = connector.DuctSystemType.ToString();
                    break;

                case Domain.DomainElectrical:
                    systemClassificationString = connector.ElectricalSystemType.ToString();
                    break;

                case Domain.DomainPiping:
                    systemClassificationString = connector.PipeSystemType.ToString();
                    break;

                case Domain.DomainCableTrayConduit:
                    systemClassificationString = "CableTrayConduit";
                    break;
                }

                systemType = GetSystemTypeFromDictionary(systemClassificationString);
            }
            catch
            {
            }
            return(systemType);
        }
Пример #2
0
        /// <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);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Get ifc distribution system type from connector's system classification string
        /// </summary>
        /// <param name="revitSystemString">The connector's system classification string.</param>
        /// <returns>ifc distribution system type.</returns>
        private static Toolkit.IFC4.IFCDistributionSystem GetSystemTypeFromDictionary(string revitSystemString)
        {
            Toolkit.IFC4.IFCDistributionSystem systemType = Toolkit.IFC4.IFCDistributionSystem.NOTDEFINED;

            if (m_SystemClassificationToIFC == null)
            {
                InitializeSystemClassifications();
            }

            if (m_SystemClassificationToIFC.ContainsKey(revitSystemString))
            {
                systemType = m_SystemClassificationToIFC[revitSystemString].First();
            }

            return(systemType);
        }
Пример #4
0
        /// <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);
                }
            }
        }