From f3fc195d2753b1fb64d511ca56a80b9130484af0 Mon Sep 17 00:00:00 2001 From: jlewin Date: Mon, 25 Mar 2019 18:17:51 -0700 Subject: [PATCH] Reduce use of deprecated z_offset field --- MatterControl.Printing/Settings/SettingsHelpers.cs | 11 +++++++---- .../UIFields/ExtruderOffsetField.cs | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/MatterControl.Printing/Settings/SettingsHelpers.cs b/MatterControl.Printing/Settings/SettingsHelpers.cs index 788d73703..8960aec46 100644 --- a/MatterControl.Printing/Settings/SettingsHelpers.cs +++ b/MatterControl.Printing/Settings/SettingsHelpers.cs @@ -187,13 +187,13 @@ namespace MatterHackers.MatterControl.SlicerConfiguration var offsetsVector3 = new List(); string currentOffsets = printerSettings.GetValue(SettingsKey.extruder_offset); string[] offsets = currentOffsets.Split(','); - var zOffset = printerSettings.GetValue(SettingsKey.z_offset); foreach (string offset in offsets) { string[] xyz = offset.Split('x'); if (xyz.Length == 2) { + var zOffset = printerSettings.GetValue(SettingsKey.z_offset); offsetsVector3.Add(new Vector3(double.Parse(xyz[0]), double.Parse(xyz[1]), -zOffset)); } else @@ -202,9 +202,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration } } - if (offsetsVector3.Count < extruderIndex) + while (offsetsVector3.Count < extruderIndex) { - offsetsVector3.Add(new Vector3(0, 0, -zOffset)); + offsetsVector3.Add(Vector3.Zero); } offsetsVector3[extruderIndex] = newOffset; @@ -230,14 +230,17 @@ namespace MatterHackers.MatterControl.SlicerConfiguration string currentOffsets = printerSettings.GetValue(SettingsKey.extruder_offset); string[] offsets = currentOffsets.Split(','); int count = 0; - var zOffset = printerSettings.GetValue(SettingsKey.z_offset); + foreach (string offset in offsets) { if (count == extruderIndex) { string[] xyz = offset.Split('x'); + if (xyz.Length == 2) { + // Import deprecated z_offset data if missing + var zOffset = printerSettings.GetValue(SettingsKey.z_offset); return new Vector3(double.Parse(xyz[0]), double.Parse(xyz[1]), -zOffset); } else diff --git a/MatterControlLib/SlicerConfiguration/UIFields/ExtruderOffsetField.cs b/MatterControlLib/SlicerConfiguration/UIFields/ExtruderOffsetField.cs index d2fbc2e5f..b0390b62e 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/ExtruderOffsetField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/ExtruderOffsetField.cs @@ -128,6 +128,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration string[] xyz = offset.Split('x'); if (xyz.Length == 2) { + // Import deprecated z_offset data if missing var zOffset = printer.Settings.GetValue(SettingsKey.z_offset); corrected += xyz[0] + "x" + xyz[1] + "x" + (-zOffset).ToString(); }