Skip to content

Gmoccapy: Fixes in calculator and tooledit_widget - #4436

Open
Sigma1912 wants to merge 2 commits into
LinuxCNC:masterfrom
Sigma1912:Gmoccapy_fix-calc-input-tool
Open

Gmoccapy: Fixes in calculator and tooledit_widget#4436
Sigma1912 wants to merge 2 commits into
LinuxCNC:masterfrom
Sigma1912:Gmoccapy_fix-calc-input-tool

Conversation

@Sigma1912

@Sigma1912 Sigma1912 commented Aug 21, 2026

Copy link
Copy Markdown
Contributor
  • Calculator no longer hands back float strings when asking for integers
  • Tooledit_widget now truncates float input values to positive integer values for the tool- and pocket number

Fixes #4435

@hansu

hansu commented Aug 21, 2026

Copy link
Copy Markdown
Member

That was quick, thanks.

I haven't dug deep into this but I wonder if we should fix it better in tooledit (or additionally).
It fails in line int(new_text) with new text = "5.000" for example.

if col in(1,2):
try:
self.model[path][col] = int(new_text)
except:
pass
# validate input for float columns
elif col in range(3,15):
try:
self.model[path][col] = f"{float(new_text.replace(',', '.')):10.4f}"
except:
pass

This would also fix it in this case. But it might be bad if this function gets accidentally a float value which is cut then.

    if col in(1,2):
        try:
            import re
            self.model[path][col] = int(re.split(r'[.,]', new_text)[0])

Calculator no longer hands back float strings when asking for integers
Tooledit_widget now truncates float input values to positive integer values for the tool- and pocket number
@Sigma1912
Sigma1912 force-pushed the Gmoccapy_fix-calc-input-tool branch from b1369d0 to bb1801a Compare August 21, 2026 14:17
@Sigma1912

Copy link
Copy Markdown
Contributor Author

I noticed that the pocket number column currently allows negative integer values, which I don't think is correct?
So Tool and Pocket number columns will now truncate any float to the absolute integer value. I'm not sure we still need the dot,comma replacement but kept it just in case.

@Sigma1912 Sigma1912 changed the title Gmoccapy: Fix calculator input for tool- and pocket-nr in tooltable Gmoccapy: Fixes in calculator and tooledit_widget Aug 21, 2026
Comment thread src/emc/usr_intf/gmoccapy/gmoccapy.py Outdated
@hansu

hansu commented Aug 22, 2026

Copy link
Copy Markdown
Member

I noticed that the pocket number column currently allows negative integer values, which I don't think is correct?

I don't know. Maybe one want to disable a tool by setting pocket to -1?
I think the bigger problem is that duplicated tool numbers and pocket numbers are allowed.

@grandixximo

Copy link
Copy Markdown
Contributor

I use duplicate pocket numbers, stacked tools

Co-authored-by: Hans Unzner <hansunzner@gmail.com>
@Sigma1912

Copy link
Copy Markdown
Contributor Author

Just checked in Axis gui (if that is anything to go by):

  • allows duplicate pocket numbers
  • errors out on negative pocket numbers

And yes, there is definitely a use for duplicate pocket number.

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.

Gmoccapy: Tool number and pocket are not editable with calculator

3 participants