prusa3d / PrusaSlicer

G-code generator for 3D printers (RepRap, Makerbot, Ultimaker etc.)
https://www.prusa3d.com/prusaslicer/
GNU Affero General Public License v3.0
7.72k stars 1.93k forks source link

No Access to Used Filament statistic where it's useful / Custom G-Code Substitutions not parsing comments #9192

Open codefaux opened 1 year ago

codefaux commented 1 year ago

Description of the bug

The title sucks, but I have a problem I can fix one of two ways.

I need to place a GCode command at the end of my GCode file, informing my printer how much filament I've just used.

My initial intent was to use [filament_used] in Printer Settings -> Custom G-Code -> End G-Code image image

My second attempt was to use Print Settings -> Output options -> Other -> G-Code Substitutions image image (PS: I know [used_filament] won't/shouldn't work here, it was a desperation attempt.)

I see that used_filament IS a placeholder, but ONLY in the output filename - making this (and most other placeholders) accessible in Printer Settings -> Custom G-Code seems entirely reasonable.

If this is unaccepable, can Print Settings -> Output options -> Other -> G-Code Substitutions be modified to parse the ENTIRE gcode file, specifically including comments? There is a lot of information provided in gcode comments, which would be useful for either LCD display lines or info tracking.

Project file & How to reproduce

Project not applicable, core functionality

Checklist of files included above

Version of PrusaSlicer

2.5.0-win64

Operating system

Windows 10

Printer model

COMPLETELY custom build, Klipper + dual MCU

bubnikv commented 1 year ago

Currently custom G-code blocks do not support placeholders for print statistics, because the placeholders are processed during G-code export while print statistics values are known first after the G-code is exported. It is technically doable to postpone processing of print statistics values in placehodlers, but it requires some additional work and it will slow down G-code export.

Placeholders are not supported in G-code substitutions. Even if they would, the same limitation applies as above: The G-code substitutions are processed during G-code export.

út 22. 11. 2022 v 0:50 odesílatel CodeFaux @.***> napsal:

Description of the bug

The title sucks, but I have a problem I can fix one of two ways.

I need to place a GCode command at the end of my GCode file, informing my printer how much filament I've just used.

My initial intent was to use [filament_used] in Printer Settings -> Custom G-Code -> End G-Code [image: image] https://user-images.githubusercontent.com/42219549/203177103-685a20cc-f547-4509-ab6c-28c7dd62a54b.png [image: image] https://user-images.githubusercontent.com/42219549/203177159-ff8b2174-3e69-4e1f-b558-3b795cfdf396.png

My second attempt was to use Print Settings -> Output options -> Other -> G-Code Substitutions [image: image] https://user-images.githubusercontent.com/42219549/203177592-3a7d703d-0dc1-437f-9252-4213ad4c2e68.png [image: image] https://user-images.githubusercontent.com/42219549/203177650-b05cae37-3379-4e12-bc20-d2ac8fd94824.png (PS: I know [used_filament] won't/shouldn't work here, it was a desperation attempt.)

I see that used_filament IS a placeholder, but ONLY in the output filename - making this (and most other placeholders) accessible in Printer Settings -> Custom G-Code seems entirely reasonable.

If this is unaccepable, can Print Settings -> Output options -> Other -> G-Code Substitutions be modified to parse the ENTIRE gcode file, specifically including comments? There is a lot of information provided in gcode comments, which would be useful for either LCD display lines or info tracking. Project file & How to reproduce

Project not applicable, core functionality Checklist of files included above

  • Project file
  • Screenshot

Version of PrusaSlicer

2.5.0-win64 Operating system

Windows 10 Printer model

COMPLETELY custom build, Klipper + dual MCU

— Reply to this email directly, view it on GitHub https://github.com/prusa3d/PrusaSlicer/issues/9192, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMPSI7O7XOVXSRIY3DZK6DWJQDC5ANCNFSM6AAAAAASHFWUSU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

codefaux commented 1 year ago

technically doable [...] but

Understood and accepted.

Placeholders are not supported in G-code substitutions Not what I was asking for, I specifically did not expect that to work. As I mentioned in my Issue, it was a last-ditch effort.

The other lines of G-Code substitution in the screenshot also did not work, none of them required placeholders -- they required processing comments.

I understand that you* (abstracting 'you' as 'the devs' because it's easier) don't want to process comments because users might/consistently do break things -- if "Expert" on the settings window isn't enough, I have a suggestion. Optionally, a checkbox alongside the others per-substitution to "Also process comments (WARNING)" with tooltip text which boils down to "This can break in unexpected ways, especially with badly formatted regexes" would cover the requirements for sufficient risk disclosure while still adding functionality beyond just my own.

This way, users who desire comment processing get their way -- at the clearly acknowledged risk of breakage -- and normal users (who probably aren't using this anyway) don't need to fuss or change expectations. It seems an acceptable compromise, and I do genuinely mean to target more than my own interests with propositions, because "do this for ME" is an absolutely unreasonable ask.

realtw commented 1 year ago

offtopic as in just a suggestion, but if the placeholder works, save into filename and maybe use another script to process the filename into a gcode append to file?

codefaux commented 1 year ago

offtopic as in just a suggestion, but if the placeholder works, save into filename and maybe use another script to process the filename into a gcode append to file?

Agent-Cain commented 11 months ago

Currently custom G-code blocks do not support placeholders for print statistics, because the placeholders are processed during G-code export while print statistics values are known first after the G-code is exported. It is technically doable to postpone processing of print statistics values in placehodlers, but it requires some additional work and it will slow down G-code export. Placeholders are not supported in G-code substitutions. Even if they would, the same limitation applies as above: The G-code substitutions are processed during G-code export.

I just used the new g-code editor tool of PS 2.7. It gives the possibility to set the variable used_filament under Print statistics, but it is still not usable ? That seems a bit odd.