SoftFever / OrcaSlicer

G-code generator for 3D printers (Bambu, Prusa, Voron, VzBot, RatRig, Creality, etc.)
https://discord.gg/P4VE9UY9gJ
GNU Affero General Public License v3.0
7.52k stars 904 forks source link

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

Closed kylek29 closed 1 month ago

kylek29 commented 5 months ago

Is there an existing issue for this feature request?

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:

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

github-actions[bot] commented 2 months ago

Orca bot: this issue is stale because it has been open for 90 days with no activity.

github-actions[bot] commented 1 month ago

Orca bot: This issue was closed because it has been inactive for 7 days since being marked as stale.