Ejemplo n.º 1
0
 /// <summary>
 /// Exports a connector instance. Almost verbatim exmaple from Revit 2012 API for Connector Class
 /// Works only for HVAC and Piping for now
 /// </summary>
 /// <param name="exporterIFC">The ExporterIFC object.</param>
 public static void Export(ExporterIFC exporterIFC)
 {
     foreach (ConnectorSet connectorSet in ExporterCacheManager.MEPCache.MEPConnectors)
     {
         Export(exporterIFC, connectorSet);
     }
     // clear local cache
     ConnectorExporter.ClearConnections();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Exports a connector instance. Almost verbatim exmaple from Revit 2012 API for Connector Class
        /// Works only for HVAC and Piping for now
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        public static void Export(ExporterIFC exporterIFC)
        {
            foreach (ConnectorSet connectorSet in ExporterCacheManager.MEPCache.MEPConnectors)
            {
                Export(exporterIFC, connectorSet);
            }
            // Create all the IfcRelNests relationships from the Dictionary for Port connection in IFC4
            CreateRelNestsFromCache(exporterIFC.GetFile());

            // clear local cache
            ConnectorExporter.ClearConnections();
        }
Ejemplo n.º 3
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);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Exports a connector instance. Almost verbatim exmaple from Revit 2012 API for Connector Class
        /// Works only for HVAC and Piping for now
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        public static void Export(ExporterIFC exporterIFC)
        {
            foreach (ConnectorSet connectorSet in ExporterCacheManager.MEPCache.MEPConnectors)
            {
                Export(exporterIFC, connectorSet);
            }

            foreach (KeyValuePair <Connector, IFCAnyHandle> connector in ExporterCacheManager.MEPCache.ConnectorCache)
            {
                ExportConnectorProperties(exporterIFC, connector.Key, connector.Value);
            }


            // Create all the IfcRelNests relationships from the Dictionary for Port connection in IFC4
            CreateRelNestsFromCache(exporterIFC.GetFile());

            // clear local cache
            ConnectorExporter.ClearConnections();
        }
Ejemplo n.º 5
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);
                }
            }
        }