Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions src/emc/usr_intf/gmoccapy/gmoccapy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4744,11 +4744,27 @@ def on_btn_back_clicked(self, widget, data=None):
new_offset = (tt.xoffset, tt.yoffset, tt.zoffset,
tt.aoffset, tt.boffset, tt.coffset,
tt.uoffset, tt.voffset, tt.woffset)
if (new_offset != self.stat.tool_offset) and ("G43" in self.active_gcodes):
message = _("Offset values for the tool in the spindle\n" \
"have been changed with tool compensation (G43) active.\n\n" \
"Do you want the new values to be applied as the currently\n" \
message = None
new_offset_is_nonzero = any(v != 0.0 for v in new_offset)
new_offset_is_zero = all(v == 0.0 for v in new_offset)
old_offset_is_zero = all(v == 0.0 for v in self.stat.tool_offset)
Comment on lines +4749 to +4750
Copy link
Member

@hansu hansu Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's a good idea to compare float with "==" ...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be fine in this case, float 0 is exact 0 and if somebody sets offset of 10nm you don't want to treat it as zero.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah true, that should be fine.

But new_offset != self.stat.tool_offset could give an unwanted message, but maybe that's not very likely....

if new_offset_is_zero and ("G43" in self.active_gcodes):
message = _("Offset values for the tool in the spindle\n"
"have been changed to zero.\n\n"
"Do you want the zero values to be applied as the currently\n"
"active tool offset?\n\n"
"This will deactivate tool compensation (G49).")
elif (new_offset != self.stat.tool_offset) and ("G43" in self.active_gcodes):
message = _("Offset values for the tool in the spindle\n"
"have been changed with tool compensation (G43) active.\n\n"
"Do you want the new values to be applied as the currently\n"
"active tool offset?")
elif new_offset_is_nonzero and old_offset_is_zero and ("G49" in self.active_gcodes):
message = _("Offset values for the tool in the spindle\n"
"have been changed from zero to non-zero.\n\n"
"Do you want to activate tool compensation (G43)\n"
"using the currently active tool offset?")
if message:
result = self.dialogs.yesno_dialog(self, message, _("Attention!"))
if result: # user says YES
self.command.mode(linuxcnc.MODE_MDI)
Expand Down
Loading