diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml index e426229f..e419a2b2 100644 --- a/.github/workflows/black.yml +++ b/.github/workflows/black.yml @@ -10,7 +10,7 @@ jobs: uses: rickstaa/action-black@v1 id: action_black with: - black_args: "./scripts/addons/cam --line-length=100" + black_args: "." - name: Create Pull Request if: steps.action_black.outputs.is_formatted == 'true' uses: peter-evans/create-pull-request@v6 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..9180c588 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,5 @@ +[tool.black] +line-length = 100 +target-version = ['py311'] +include = '\.py' + diff --git a/scripts/addons/cam/blender_manifest.toml b/scripts/addons/cam/blender_manifest.toml index 398f6e3a..16efa2c9 100644 --- a/scripts/addons/cam/blender_manifest.toml +++ b/scripts/addons/cam/blender_manifest.toml @@ -1,7 +1,7 @@ -schema_version = "1.0.57" +schema_version = "1.0.60" id = "fabex" -version = "1.0.57" +version = "1.0.60" name = "Fabex CNC (formerly BlenderCAM)" tagline = "G-code Generation Tools" maintainer = "Alain Pelletier and Contributors" diff --git a/scripts/addons/cam/parametric.py b/scripts/addons/cam/parametric.py index 6aeaa6ee..f10bbdec 100644 --- a/scripts/addons/cam/parametric.py +++ b/scripts/addons/cam/parametric.py @@ -87,7 +87,7 @@ def create_parametric_curve( use_cubic: bool = True, iterations: int = 8, resolution_u: int = 10, - **kwargs + **kwargs, ): """ Creates a Blender bezier curve object from a parametric function. diff --git a/scripts/addons/cam/utilities/bounds_utils.py b/scripts/addons/cam/utilities/bounds_utils.py index 538ba873..394cb844 100644 --- a/scripts/addons/cam/utilities/bounds_utils.py +++ b/scripts/addons/cam/utilities/bounds_utils.py @@ -10,6 +10,7 @@ from .shapely_utils import shapely_to_curve, shapely_to_multipolygon from .simple_utils import ( activate, progress, + unit_value_to_string, ) @@ -242,14 +243,38 @@ def get_bounds(o): o.max.z = o.source_image_offset.z s = bpy.context.scene m = s.cam_machine - # make sure this message only shows once and goes away once fixed - o.info.warnings.replace("Operation Exceeds Your Machine Limits\n", "") - if ( - o.max.x - o.min.x > m.working_area.x - or o.max.y - o.min.y > m.working_area.y - or o.max.z - o.min.z > m.working_area.z - ): - o.info.warnings += "Operation Exceeds Your Machine Limits\n" + + x_delta_range = o.max.x - o.min.x + y_delta_range = o.max.y - o.min.y + z_delta_range = o.max.z - o.min.z + + x_is_exceeded = x_delta_range > m.working_area.x + y_is_exceeded = y_delta_range > m.working_area.y + z_is_exceeded = z_delta_range > m.working_area.z + + if x_is_exceeded or y_is_exceeded or z_is_exceeded: + exceed_msg = "Operation Exceeds Your Machine Limits (range > working area)\n" + + # Do not append more than one such a warning + if exceed_msg not in o.info.warnings: + o.info.warnings += exceed_msg + + if x_is_exceeded: + o.info.warnings += ( + f"Axis X[ range:{unit_value_to_string(x_delta_range)}" + + f", working area:{unit_value_to_string(m.working_area.x)}]\n" + ) + if y_is_exceeded: + o.info.warnings += ( + f"Axis Y[ range:{unit_value_to_string(y_delta_range)}" + + f", working area:{unit_value_to_string(m.working_area.y)}]\n" + ) + if z_is_exceeded: + o.info.warnings += ( + f"Axis Z[ range:{unit_value_to_string(z_delta_range)}" + + f", working area:{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 if addon_prefs.show_popups: diff --git a/scripts/addons/cam/utilities/operation_utils.py b/scripts/addons/cam/utilities/operation_utils.py index 25172c1f..294ebeba 100644 --- a/scripts/addons/cam/utilities/operation_utils.py +++ b/scripts/addons/cam/utilities/operation_utils.py @@ -12,6 +12,7 @@ import bpy from bpy_extras import object_utils from .simple_utils import get_cache_path +from .simple_utils import unit_value_to_string from ..constants import was_hidden_dict diff --git a/scripts/addons/cam/version.py b/scripts/addons/cam/version.py index 3945ec35..b43200ed 100644 --- a/scripts/addons/cam/version.py +++ b/scripts/addons/cam/version.py @@ -1 +1 @@ -__version__ = (1, 0, 57) +__version__=(1,0,60) \ No newline at end of file