From 245e09cd371c362543606c85f16017aa52d19614 Mon Sep 17 00:00:00 2001 From: Rob Date: Thu, 13 Feb 2025 10:11:32 -0500 Subject: [PATCH] Warning Icons, text cleanup, Collection debug starts --- scripts/addons/cam/gcode_path.py | 3 ++- scripts/addons/cam/properties/operation_props.py | 2 +- scripts/addons/cam/strategy.py | 2 +- scripts/addons/cam/ui/panels/info_panel.py | 15 +++++++++++---- scripts/addons/cam/ui/panels/popup_panel.py | 16 ++++++++++------ scripts/addons/cam/utilities/bounds_utils.py | 10 +++++----- 6 files changed, 30 insertions(+), 18 deletions(-) diff --git a/scripts/addons/cam/gcode_path.py b/scripts/addons/cam/gcode_path.py index 3b274dbc..87ec49bb 100644 --- a/scripts/addons/cam/gcode_path.py +++ b/scripts/addons/cam/gcode_path.py @@ -729,7 +729,8 @@ def check_memory_limit(o): if res > limit: ratio = res / limit o.optimisation.pixsize = o.optimisation.pixsize * sqrt(ratio) - o.info.warnings += " \nMemory Limit Exceeded!\n" + o.info.warnings += " \n!!! Memory Error !!!\n" + o.info.warnings += "Memory Limit Exceeded!\n" o.info.warnings += f"Detail Size Increased to {round(o.optimisation.pixsize, 5)}\n" print("Changing Sampling Resolution to %f" % o.optimisation.pixsize) diff --git a/scripts/addons/cam/properties/operation_props.py b/scripts/addons/cam/properties/operation_props.py index 7355bb8d..fbf819fa 100644 --- a/scripts/addons/cam/properties/operation_props.py +++ b/scripts/addons/cam/properties/operation_props.py @@ -1152,7 +1152,7 @@ class CAM_OPERATION_Properties(PropertyGroup): ambient = sgeometry.Polygon() operation_limit = sgeometry.Polygon() borderwidth = 50 - object = None + objects = None path_object_name: StringProperty(name="Path Object", description="Actual CNC path") ################# diff --git a/scripts/addons/cam/strategy.py b/scripts/addons/cam/strategy.py index e5c903dd..42e90350 100644 --- a/scripts/addons/cam/strategy.py +++ b/scripts/addons/cam/strategy.py @@ -225,7 +225,7 @@ async def cutout(o): for ch in chunksFromCurve: ch.reverse() - if o.cut_type == "INSIDE": # there would bee too many conditions above, + if o.cut_type == "INSIDE": # there would be too many conditions above, # so for now it gets reversed once again when inside cutting. for ch in chunksFromCurve: ch.reverse() diff --git a/scripts/addons/cam/ui/panels/info_panel.py b/scripts/addons/cam/ui/panels/info_panel.py index 1442c7b6..e4cd8bce 100644 --- a/scripts/addons/cam/ui/panels/info_panel.py +++ b/scripts/addons/cam/ui/panels/info_panel.py @@ -47,10 +47,17 @@ class CAM_INFO_Panel(CAMParentPanel, Panel): box = main.box() col = box.column(align=True) col.alert = True - col.label(text="!!! Warning !!!", icon="ERROR") + col.label(text="!!! WARNING !!!", icon="ERROR") for line in self.op.info.warnings.rstrip("\n").split("\n"): if len(line) > 0: - col.label(text=line, icon="ERROR") + icon = "BLANK1" + if line.startswith(("Path", "Operation", "X", "Y", "Z")): + icon = "MOD_WIREFRAME" + if line.startswith(("Memory", "Detail")): + icon = "MEMORY" + if line.startswith(("!!!")): + icon = "ERROR" + col.label(text=line, icon=icon) # Cutter Engagement if not self.op.strategy == "CUTOUT" and not self.op.cutter_type in ["LASER", "PLASMA"]: @@ -125,7 +132,7 @@ class CAM_INFO_Panel(CAMParentPanel, Panel): return cost_per_second = bpy.context.scene.cam_machine.hourly_rate / 3600 - total_cost = self.op.info.duration * 60 * cost_per_second - op_cost = f"${total_cost:.2f} (${cost_per_second:.2f}/s)" + total_cost = self.op.info.duration * 6000 * cost_per_second + op_cost = f"${total_cost:.2f}" # (${cost_per_second:.2f}/s)" title_col.label(text="Cost:") value_col.label(text=op_cost, icon="TAG") diff --git a/scripts/addons/cam/ui/panels/popup_panel.py b/scripts/addons/cam/ui/panels/popup_panel.py index a2d73d6a..e3495c4e 100644 --- a/scripts/addons/cam/ui/panels/popup_panel.py +++ b/scripts/addons/cam/ui/panels/popup_panel.py @@ -26,7 +26,7 @@ class CAM_Popup_Panel(Operator): y = int(height / 2 + v_offset) context.window.cursor_warp(x, y) - return wm.invoke_props_dialog(self, width=popup_width, title="Fabex CNC/CAM") + return wm.invoke_props_dialog(self, width=popup_width, title="Fabex CNC") def draw(self, context): layout = self.layout @@ -45,12 +45,16 @@ class CAM_Popup_Panel(Operator): if not self.op.info.warnings == "": # Operation Warnings box = layout.box() - # box.alert = True - row = box.row(align=True) - row.alignment = "CENTER" - col = row.column(align=True) + col = box.column(align=True) col.alert = True col.label(text="!!! WARNING !!!", icon="ERROR") for line in self.op.info.warnings.rstrip("\n").split("\n"): if len(line) > 0: - col.label(text=line, icon="ERROR") + icon = "BLANK1" + if line.startswith(("Bounds", "Path", "Operation", "X", "Y", "Z")): + icon = "MOD_WIREFRAME" + if line.startswith(("Memory", "Detail")): + icon = "MEMORY" + if line.startswith(("!!!")): + icon = "ERROR" + col.label(text=line, icon=icon) diff --git a/scripts/addons/cam/utilities/bounds_utils.py b/scripts/addons/cam/utilities/bounds_utils.py index c98a8f48..8247a596 100644 --- a/scripts/addons/cam/utilities/bounds_utils.py +++ b/scripts/addons/cam/utilities/bounds_utils.py @@ -254,22 +254,22 @@ def get_bounds(o): z_is_exceeded = z_delta_range > m.working_area.z if x_is_exceeded or y_is_exceeded or z_is_exceeded: - exceed_msg = " \nPath Exceeds Machine Limits!\n" + exceed_msg = " \n!!! Bounds Error !!!\n" # Do not append more than one such a warning if exceed_msg not in o.info.warnings: o.info.warnings += exceed_msg + o.info.warnings += "Path Exceeds Machine Limits!\n" o.info.warnings += "Operation Area > Work Area\n" - o.info.warnings += " \n" if x_is_exceeded: - o.info.warnings += f"X: {unit_value_to_string(x_delta_range)} > {unit_value_to_string(m.working_area.x)}\n \n" + o.info.warnings += f"X: {unit_value_to_string(x_delta_range)} > {unit_value_to_string(m.working_area.x)}\n" if y_is_exceeded: - o.info.warnings += f"Y: {unit_value_to_string(y_delta_range)} > {unit_value_to_string(m.working_area.y)}\n \n" + o.info.warnings += f"Y: {unit_value_to_string(y_delta_range)} > {unit_value_to_string(m.working_area.y)}\n" if z_is_exceeded: - o.info.warnings += f"Z: {unit_value_to_string(z_delta_range)} > {unit_value_to_string(m.working_area.z)}\n \n" + o.info.warnings += f"Z: {unit_value_to_string(z_delta_range)} > {unit_value_to_string(m.working_area.z)}\n" if not o.info.warnings == "": addon_prefs = bpy.context.preferences.addons["bl_ext.user_default.fabex"].preferences