Your Products have been synced, click here to refresh
Thanks again for all responses. I'll post an update soon on how it all works out!
private void OutputPcDmisDataToTextFile() { StringBuilder sb = new StringBuilder(); //these strings will hold the pc-dmis trace data string dieNumber = string.Empty; string partNumber = string.Empty; string productType = string.Empty; string castingMachine = string.Empty; string cmmOperator = string.Empty; //other strings go here var PCCommands = PCPart.Commands; string pcCommandId = string.Empty; var pcDmisOutputList = new List<PcDmisOutput>(); //PcDmisOutput is just a small class that holds command ID and measurement/deviation data to allow us to go from 2 loops through the pc-dmis data down to 1 var commandsCount = PCPart.Commands.Count; for (int i = 1; i <= commandsCount; i++) { PCCommand = PCPart.Commands.Item(i); if (PCCommand != null) { if (PCCommand.IsTraceField) { traceName = PCCommand.GetText(PCDLRN.ENUM_FIELD_TYPES.TRACE_NAME, 0); switch (traceName) { case "Die Number": dieNumber = PCCommand.GetText(PCDLRN.ENUM_FIELD_TYPES.TRACE_VALUE, 0); break; case "Part Number": //All partNumber = PCCommand.GetText(PCDLRN.ENUM_FIELD_TYPES.TRACE_VALUE, 0); break; case "Cast Date": //All this.CastDate = PCCommand.GetText(PCDLRN.ENUM_FIELD_TYPES.TRACE_VALUE, 0); break; case "Product Type": //All productType = PCCommand.GetText(PCDLRN.ENUM_FIELD_TYPES.TRACE_VALUE, 0); break; case "Casting Machine": //puma cast castingMachine = PCCommand.GetText(PCDLRN.ENUM_FIELD_TYPES.TRACE_VALUE, 0); break; case "CMM Operator": //All cmmOperator = PCCommand.GetText(PCDLRN.ENUM_FIELD_TYPES.TRACE_VALUE, 0); break; //other trace info is brought back here } } if (PCCommand.IsDimension) { //sometimes we have a command id but no axis so these statements ensure we have both if (!string.IsNullOrEmpty(PCCommand.ID) && !string.IsNullOrEmpty(PCCommand.DimensionCommand.AxisLetter)) { pcDmisOutputList.Add(new PcDmisOutput(PCCommand.ID, PCCommand.DimensionCommand.Deviation, PCCommand.DimensionCommand.Measured)); } else if (!string.IsNullOrEmpty(PCCommand.ID) && string.IsNullOrEmpty(PCCommand.DimensionCommand.AxisLetter)) { pcCommandId = PCCommand.ID; } else if (string.IsNullOrEmpty(PCCommand.ID) && !string.IsNullOrEmpty(PCCommand.DimensionCommand.AxisLetter)) { pcDmisOutputList.Add(new PcDmisOutput(pcCommandId, PCCommand.DimensionCommand.Deviation, PCCommand.DimensionCommand.Measured)); } } } } foreach (var pcDmisOutput in pcDmisOutputList) { sb.AppendLine(string.Format(//omitting my code but this is where we build up a string with the following: dieNumber partNumber productType castingMachine cmmOperator, pcDmisOutput.CommandId, pcDmisOutput.GetDeviationOrMeasurement() //note: the GetDeviationOrMeasurement() method returns either the deviation or measurement based on the one that pc-dmis populated when it performed the measurement } writeToDataFile(sb.ToString()); }
Thanks again for all responses. I'll post an update soon on how it all works out!
private void OutputPcDmisDataToTextFile() { StringBuilder sb = new StringBuilder(); //these strings will hold the pc-dmis trace data string dieNumber = string.Empty; string partNumber = string.Empty; string productType = string.Empty; string castingMachine = string.Empty; string cmmOperator = string.Empty; //other strings go here var PCCommands = PCPart.Commands; string pcCommandId = string.Empty; var pcDmisOutputList = new List<PcDmisOutput>(); //PcDmisOutput is just a small class that holds command ID and measurement/deviation data to allow us to go from 2 loops through the pc-dmis data down to 1 var commandsCount = PCPart.Commands.Count; for (int i = 1; i <= commandsCount; i++) { PCCommand = PCPart.Commands.Item(i); if (PCCommand != null) { if (PCCommand.IsTraceField) { traceName = PCCommand.GetText(PCDLRN.ENUM_FIELD_TYPES.TRACE_NAME, 0); switch (traceName) { case "Die Number": dieNumber = PCCommand.GetText(PCDLRN.ENUM_FIELD_TYPES.TRACE_VALUE, 0); break; case "Part Number": //All partNumber = PCCommand.GetText(PCDLRN.ENUM_FIELD_TYPES.TRACE_VALUE, 0); break; case "Cast Date": //All this.CastDate = PCCommand.GetText(PCDLRN.ENUM_FIELD_TYPES.TRACE_VALUE, 0); break; case "Product Type": //All productType = PCCommand.GetText(PCDLRN.ENUM_FIELD_TYPES.TRACE_VALUE, 0); break; case "Casting Machine": //puma cast castingMachine = PCCommand.GetText(PCDLRN.ENUM_FIELD_TYPES.TRACE_VALUE, 0); break; case "CMM Operator": //All cmmOperator = PCCommand.GetText(PCDLRN.ENUM_FIELD_TYPES.TRACE_VALUE, 0); break; //other trace info is brought back here } } if (PCCommand.IsDimension) { //sometimes we have a command id but no axis so these statements ensure we have both if (!string.IsNullOrEmpty(PCCommand.ID) && !string.IsNullOrEmpty(PCCommand.DimensionCommand.AxisLetter)) { pcDmisOutputList.Add(new PcDmisOutput(PCCommand.ID, PCCommand.DimensionCommand.Deviation, PCCommand.DimensionCommand.Measured)); } else if (!string.IsNullOrEmpty(PCCommand.ID) && string.IsNullOrEmpty(PCCommand.DimensionCommand.AxisLetter)) { pcCommandId = PCCommand.ID; } else if (string.IsNullOrEmpty(PCCommand.ID) && !string.IsNullOrEmpty(PCCommand.DimensionCommand.AxisLetter)) { pcDmisOutputList.Add(new PcDmisOutput(pcCommandId, PCCommand.DimensionCommand.Deviation, PCCommand.DimensionCommand.Measured)); } } } } foreach (var pcDmisOutput in pcDmisOutputList) { sb.AppendLine(string.Format(//omitting my code but this is where we build up a string with the following: dieNumber partNumber productType castingMachine cmmOperator, pcDmisOutput.CommandId, pcDmisOutput.GetDeviationOrMeasurement() //note: the GetDeviationOrMeasurement() method returns either the deviation or measurement based on the one that pc-dmis populated when it performed the measurement } writeToDataFile(sb.ToString()); }
© 2025 Hexagon AB and/or its subsidiaries. | Privacy Policy | Cloud Services Agreement |