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

Port New Macro Language from PrusaSlicer 2.6.4+to OrcaSlicer #5995

Open
1 task done
kylek29 opened this issue Jul 2, 2024 · 0 comments
Open
1 task done

Port New Macro Language from PrusaSlicer 2.6.4+to OrcaSlicer #5995

kylek29 opened this issue Jul 2, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@kylek29
Copy link

kylek29 commented Jul 2, 2024

Is there an existing issue for this feature request?

  • I have searched the existing issues

Is your feature request related to a problem?

N/A

Which printers will be beneficial to this feature?

All

Describe the solution you'd like

PrusaSlicer added the ability to declare global and local variable names within Custom GCode scripts. From what I can see, this has not been ported over.

The advantage of the new macro language is it allows for regex matching (Perl syntax) and global scope assignment. For a worked example of where you'd use this:

Note: global vars are only available after they're declared, so Start G-Code is the best place to declare them if you need them everywhere.

Example Scripts:

Start G-Code:

; PSLICER-NEW-MACRO-DEMO
{global test_var = 5 + e_retracted[0]}
{global varb = 20}
{global vara = 35}

Pause G-Code (can be any section):

{test_var} ; Should output 5 as the calculated value. Passed from the global declaration in the Start GCode.


; PSLICER-PLACEHOLDER-REGEX
{if printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/};Printer is Prusa{endif}

; PSLICER-COMBINED-DEMO
{varb + vara} ; Test output, should be 55 as A = 35, B = 20 from Start G-Code declaration.
{
   if printer_notes=~/.*MY_DEMO_TEST.*/ then
      varb = 50;
   endif
}

{varb + vara} ; Should be 85, as we updated the global B variable in the last section. But only if we put the text MY_DEMO_TEST in the printer notes.

Example Description:

A few examples are intertwined here:

  • Output a globally declared math expression {test_var}
  • If printer_notes contains the string PRINTER_VENDOR_PRUSA3D, output the comment ";Printer is Prusa"
  • Output the addition of the globally declared varb and vara
  • If printer_notes contains the string MY_DEMO_TEST, change the global varb to 50
  • Reoutput the prior varb + vara expression, if printer_notes has the MY_DEMO_TEST it should be 85, else it should be the prior 55.

Where might you use this? Custom value overrides. You can put keyword flags into any note fields (machine, filament, project) and your G-Code scripts will express the logic. For example, maybe you want a quick way to override the Z-Offset based on the platename (or project name), you could do a Regex lookup for your own formatted syntax (e.g. {{Z-0.15}} and have that z offset expressed.

Describe alternatives you've considered

No alternatives appear to exist for the new syntax.

Additional context

Documentation:

Code:

_May not be all of it, just what I was able to find. Additionally, this may not contain all of the RegEx logic as PrusaSlicer also has a RegEx processor in Print Settings -> Output Settings -> Other.

PrusaSlicer generated .3mf and .gcode attached.

Example-NewMacroLang-Shape-Box.3mf.zip

@kylek29 kylek29 added the enhancement New feature or request label Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant