private void extract_mep_data(Document rvtDoc) { try { FabricationConfiguration config = FabricationConfiguration.GetFabricationConfiguration(rvtDoc); if (config == null) { LogTrace("GetFabricationConfiguration failed"); return; } GetFabricationConnectors(config); FilteredElementCollector m_Collector = new FilteredElementCollector(rvtDoc); m_Collector.OfClass(typeof(FabricationPart)); IList <Element> fps = m_Collector.ToElements(); string outputFullPath = System.IO.Directory.GetCurrentDirectory() + "\\" + OUTPUT_FILE; FileStream fs = new FileStream(outputFullPath, System.IO.FileMode.Create, System.IO.FileAccess.Write); StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8); foreach (Element el in fps) { FabricationPart fp = el as FabricationPart; LogTrace("Reading data of one FabricationPart: " + fp.Name); sw.WriteLine("Name: " + fp.Name); foreach (Parameter para in el.Parameters) { sw.WriteLine(" " + GetParameterInformation(para, rvtDoc)); } sw.WriteLine(" ProductName: " + fp.ProductName); sw.WriteLine(" ServiceName: " + fp.ServiceName); sw.WriteLine(" Service Type: " + config.GetServiceTypeName(fp.ServiceType)); sw.WriteLine(" SpoolName: " + fp.SpoolName); sw.WriteLine(" Alias: " + fp.Alias); sw.WriteLine(" CID: " + fp.ItemCustomId.ToString()); sw.WriteLine(" Domain Type: " + fp.DomainType.ToString()); if (fp.IsAHanger()) { string rodKitName = " None"; var rodKit = fp.HangerRodKit; if (rodKit > 0) { rodKitName = config.GetAncillaryGroupName(fp.HangerRodKit) + ": " + config.GetAncillaryName(fp.HangerRodKit); } sw.WriteLine(" Hanger Rod Kit: " + rodKitName); } var insSpec = config.GetInsulationSpecificationGroup(fp.InsulationSpecification) + ": " + config.GetInsulationSpecificationName(fp.InsulationSpecification); sw.WriteLine(" Insulation Specification: " + insSpec); sw.WriteLine(" Has No Connections: " + fp.HasNoConnections().ToString()); sw.WriteLine(" Item Number: " + fp.ItemNumber); var material = config.GetMaterialGroup(fp.Material) + ": " + config.GetMaterialName(fp.Material); sw.WriteLine(" Material: " + material); sw.WriteLine(" Part Guid: " + fp.PartGuid.ToString()); sw.WriteLine(" Part Status: " + config.GetPartStatusDescription(fp.PartStatus)); sw.WriteLine(" Product Code: " + fp.ProductCode); var spec = config.GetSpecificationGroup(fp.Specification) + ": " + config.GetSpecificationName(fp.Specification); sw.WriteLine(" Specification: " + spec); sw.WriteLine(" Dimensions from Fabrication Dimension Definition:"); foreach (FabricationDimensionDefinition dmdef in fp.GetDimensions()) { sw.WriteLine(" " + dmdef.Name + ":" + fp.GetDimensionValue(dmdef).ToString()); } int index = 1; sw.WriteLine(" Connectors:"); foreach (Connector con in fp.ConnectorManager.Connectors) { sw.WriteLine(" C" + index.ToString()); FabricationConnectorInfo fci = con.GetFabricationConnectorInfo(); sw.WriteLine(" Connector Info:" + m_connGroups[fci.BodyConnectorId] + " " + m_connNames[fci.BodyConnectorId]); sw.WriteLine(" IsBodyConnectorLocked:" + fci.IsBodyConnectorLocked.ToString()); sw.WriteLine(" Shape:" + con.Shape.ToString()); try { sw.WriteLine(" Radius:" + con.Radius.ToString()); } catch (Exception ex) { } try { sw.WriteLine(" PressureDrop:" + con.PressureDrop.ToString()); } catch (Exception ex) { } try { sw.WriteLine(" Width:" + con.Width.ToString()); } catch (Exception ex) { } try { sw.WriteLine(" Height:" + con.Height.ToString()); } catch (Exception ex) { } try { sw.WriteLine(" PipeSystemType:" + con.PipeSystemType.ToString()); } catch (Exception ex) { } try { sw.WriteLine(" VelocityPressure:" + con.VelocityPressure.ToString()); } catch (Exception ex) { } try { sw.WriteLine(" DuctSystemType:" + con.DuctSystemType.ToString()); } catch (Exception ex) { } index++; } } LogTrace("Saving file..."); sw.Close(); fs.Close(); } catch (Exception ex) { LogTrace("Unexpected Exception..." + ex.ToString()); } }
/// <summary> /// Convenience method to get all fabrication material identifiers from the /// specified fabrication configuration. /// </summary> /// <param name="config"> /// The fabrication configuration. /// </param> /// <returns> /// Returns a list of all the fabrication material identifiers for this /// fabrication configuration. /// </returns> void GetMaterials(FabricationConfiguration config) { m_materialIds = config.GetAllMaterials(null); m_materialGroups = new List<string>(); m_materialNames = new List<string>(); for (int i = 0; i < m_materialIds.Count; i++) { m_materialGroups.Add(config.GetMaterialGroup(m_materialIds[i])); m_materialNames.Add(config.GetMaterialName(m_materialIds[i])); } }