Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempting to use calculations in Start/End GCode breaks it without warning about it #9906

Closed
1 of 2 tasks
BloodyRain2k opened this issue May 25, 2021 · 7 comments
Closed
1 of 2 tasks
Labels
Status: Under Investigation The issue has been confirmed or is assumed to be likely to be a real issue. It's pending discussion.

Comments

@BloodyRain2k
Copy link

BloodyRain2k commented May 25, 2021

Application Version

4.9.1

Platform

Win 7 x64

Printer

CR6

Reproduction steps

Enter characters use in equations into the { } of a placeholder in the Start/End GCode
Close the window and let it re-slice the part
Save the GCode to disk and verify that it failed to replace the placeholders without any indication

image

Actual results

I want to point out that this is even the 2nd attempt where I commented out the line, and it still broke.

image

Expected results

If it fails to fill in the placeholders because there's something in the GCode that breaks it, I expect it to give me a warning at the very least.

But I can do the whole process and nothing out of the ordinary happens.

On a side note: I was hoping it would be possible to use math with the placeholders, but it was only a test for a tiny QoL thing.

Checklist of files to include

  • Log file
  • Project file

Additional information & file uploads

Bearing_Clip_686.zip

@BloodyRain2k BloodyRain2k added the Type: Bug The code does not produce the intended behavior. label May 25, 2021
@fvrmr
Copy link
Contributor

fvrmr commented May 27, 2021

Hi @BloodyRain2k thank you for your report.
It is expected behaviour you can't uses formulas in the start g-code, so that's why it isn't working.

@fvrmr
Copy link
Contributor

fvrmr commented May 31, 2021

Hi @BloodyRain2k I have discussed it with the team and we decided to defer this issue.
It is not a priority right now to add a warning when you want to use formulas in the start/end gcode.
Hope you understand.

@fvrmr fvrmr added the Status: Deferred We don't have time to work on this for now but intend to in the future. label May 31, 2021
@BloodyRain2k
Copy link
Author

BloodyRain2k commented May 31, 2021

I can understand not wanting to make calculations at this point a priority, but not adding a warning when something broke the parser? That seems bad.

Like when I tried to change my experiment to

M109 S190
M300 P100 S660
M109 S{material_print_layer_0_temperature}

I made a typo in the first line and it read M109 S{190} instead, which also broke every other placeholder, just like the commented line with the placeholder calculation.

At the very least it should warn if something went wrong while filling in the placeholders.

@fvrmr
Copy link
Contributor

fvrmr commented Jun 1, 2021

I understand, but is not a priority for us to add this, since we have more important bugs to fix. A pull request is always welcome.

@Ghostkeeper
Copy link
Collaborator

People add stuff in brackets to their start g-code all the time, especially for firmware like Repetier's. Can't warn them all the time for things that are perfectly valid. So what distinguishes a perfectly valid g-code intended for third party software from an incorrectly formatted setting key intended for Cura to read?

@FroggieFrog
Copy link

FroggieFrog commented Apr 21, 2023

This issue is still present with 5.3.1.
A solution could be to ignore commented lines that fail to parse, but show a warning if the line failed to parse but is not commented.

; do not show warning AND continue to replace other variables
; no arithmetic in cura
;M190 S{material_bed_temperature_layer_0 * 0.7}

; is still parsed and replaced despite the above statemant
M190 S{material_bed_temperature_layer_0}

; show warning | maybe stop slicing
M190 S{material_bed_temperature_layer_0 * 0.7}

relevant information from cura.log:

2023-04-21 09:20:41,870 - INFO - [MainThread] CuraEngineBackend.CuraEngineBackend.slice [290]: Starting to slice...
2023-04-21 09:20:41,870 - DEBUG - [MainThread] CuraEngineBackend.CuraEngineBackend.slice [309]: Going to slice build plate [0]!
2023-04-21 09:20:41,984 - WARNING - [JobQueueWorker [2]] CuraEngineBackend.StartSliceJob.get_value [85]: Unable to replace 'material_bed_temperature_layer_0 * 0' placeholder in start/end g-code
2023-04-21 09:20:41,984 - WARNING - [JobQueueWorker [2]] CuraEngineBackend.StartSliceJob._expandGcodeTokens [419]: Exception: Unable to do token replacement on start/end g-code
2023-04-21 09:20:41,985 - WARNING - [JobQueueWorker [2]] CuraEngineBackend.StartSliceJob._expandGcodeTokens [419]: Traceback (most recent call last):
2023-04-21 09:20:41,985 - WARNING - [JobQueueWorker [2]] CuraEngineBackend.StartSliceJob._expandGcodeTokens [419]:   File "C:\Program Files\UltiMaker Cura\share\cura\plugins\CuraEngineBackend\StartSliceJob.py", line 417, in _expandGcodeTokens
2023-04-21 09:20:41,986 - WARNING - [JobQueueWorker [2]] CuraEngineBackend.StartSliceJob._expandGcodeTokens [419]:     return str(fmt.format(value, **settings))
2023-04-21 09:20:41,986 - WARNING - [JobQueueWorker [2]] CuraEngineBackend.StartSliceJob._expandGcodeTokens [419]:   File "string.py", line 161, in format
2023-04-21 09:20:41,987 - WARNING - [JobQueueWorker [2]] CuraEngineBackend.StartSliceJob._expandGcodeTokens [419]:   File "string.py", line 165, in vformat
2023-04-21 09:20:41,987 - WARNING - [JobQueueWorker [2]] CuraEngineBackend.StartSliceJob._expandGcodeTokens [419]:   File "string.py", line 205, in _vformat
2023-04-21 09:20:41,988 - WARNING - [JobQueueWorker [2]] CuraEngineBackend.StartSliceJob._expandGcodeTokens [419]:   File "string.py", line 276, in get_field
2023-04-21 09:20:41,988 - WARNING - [JobQueueWorker [2]] CuraEngineBackend.StartSliceJob._expandGcodeTokens [419]: AttributeError: 'str' object has no attribute '7'
2023-04-21 09:20:42,041 - DEBUG - [MainThread] CuraEngineBackend.CuraEngineBackend._onStartSliceCompleted [516]: Sending slice message took 0.17104196548461914 seconds

@GregValiant GregValiant added Status: Under Investigation The issue has been confirmed or is assumed to be likely to be a real issue. It's pending discussion. and removed Type: Bug The code does not produce the intended behavior. Status: Deferred We don't have time to work on this for now but intend to in the future. labels Nov 19, 2024
@GregValiant
Copy link
Collaborator

This is now available in Cura current versions. I'll close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Under Investigation The issue has been confirmed or is assumed to be likely to be a real issue. It's pending discussion.
Projects
None yet
Development

No branches or pull requests

5 participants