Skip to content

fix(print-and-cut): tolerate 4-axis position reports - #395

Merged
knipknap merged 2 commits into
mainfrom
fix/394-print-cut-wizard-4axis
Sep 9, 2026
Merged

fix(print-and-cut): tolerate 4-axis position reports#395
knipknap merged 2 commits into
mainfrom
fix/394-print-cut-wizard-4axis

Conversation

@knipknap

@knipknap knipknap commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

The Print & Cut wizard crashed on launch for 4-axis machines (e.g. X/Y/Z/A with a rotary) with:

ValueError: too many values to unpack (expected 3)

at _update_laser_position (wizard.py:606).

Machine.get_current_position() returns a variable-length Pos tuple (tuple[float | None, ...], driver.py:138). The GRBL parser keeps a 4th axis value when the firmware reports one (e.g. <Idle|MPos:-300.000,-50.000,0.000,0.000|...>), so work_pos has four entries on such machines. The wizard assumed a fixed 3-tuple in two places and hard-unpacked it.

Changes

  • _update_laser_position: read only X/Y via indexing with a length check instead of unpacking a 3-tuple
  • _on_record_clicked: same fix (would have crashed identically when recording a point)
  • Add regression tests (tests/ui_gtk/test_print_and_cut_wizard.py) covering 3- and 4-value positions, invalid positions, and point recording

Fixes #394

Testing

  • pytest tests/ui_gtk/test_print_and_cut_wizard.py -m ui under xvfb: 8 passed
  • pytest tests/machine/models/test_machine.py tests/machine/driver/grbl/test_grbl_util.py: 338 passed
  • ruff format/check, flake8, pyflakes clean (one pre-existing pyflakes warning in the sketcher addon on main)

Machine.get_current_position() returns a variable-length Pos tuple;
machines with an extra rotary axis (e.g. GRBL A-axis) report four
values. The wizard unpacked a fixed 3-tuple, raising ValueError and
preventing the wizard from launching.

Unpack only X/Y in both call sites and add regression tests.

Fixes #394
Guard against spec_from_file_location returning None and consolidate
module loading into a single helper so loader narrowing applies.
@knipknap
knipknap merged commit 189bb57 into main Sep 9, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Print & Cut wizard not launching

1 participant