Coder Social home page Coder Social logo

cp2004 / octoprint-gcodemacros Goto Github PK

View Code? Open in Web Editor NEW
7.0 7.0 2.0 209 KB

Configure custom gcode macros you can use anywhere!

Home Page: https://plugins.octoprint.org/plugins/gcode_macro

License: GNU Affero General Public License v3.0

JavaScript 2.08% Python 93.98% SCSS 1.00% Jinja 2.95%
gcode macro octoprint

octoprint-gcodemacros's Introduction

Hey there ๐Ÿ‘‹

Here are some of my featured projects:

Recent releases ๐Ÿ”–

Supporting my projects

Enjoyed using a plugin? You can support their development through GitHub Sponsors. Sponsor monthly, one-time and choose a custom amount. You can choose!

โค๏ธ Sponsor

octoprint-gcodemacros's People

Contributors

cp2004 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

octoprint-gcodemacros's Issues

@BEDLEVELVISUALIZER

Adding @BEDLEVELVISUALIZER to a macro seems to get ignored. I'm using both the BedLevelVisualizer and BLTouch plugins

I've created a Macro that includes the @BEDLEVELVISUALIZER then used that macro in the probe bed script on the BLTouch Plugin. The BedLevelVisualizer doesn't pickup the command and start watching for the mesh.
@abl macro

M140 S50 ; starting by heating the bed for nominal mesh accuracy
M117 Homing all axes ; send message to printer display
G28      ; home all axes
M420 S0  ; Turning off bed leveling while probing, if firmware is set
         ; to restore after G28
M117 Heating the bed ; send message to printer display
M190 S50 ; waiting until the bed is fully warmed up
M117 Creating the bed mesh levels ; send message to printer display
M155 S30 ; reduce temperature reporting rate to reduce output pollution
@BEDLEVELVISUALIZER	; tell the plugin to watch for reported mesh
G29 T	   ; run bilinear probing
M155 S3  ; reset temperature reporting
M140 S0 ; cooling down the bed
M500 ; store mesh in EEPROM
M117 Bed mesh levels completed ; send message to printer display

If I change the BLTouch Plugin bed probe to this it works fine.

@BEDLEVELVISUALIZER
@ABL

If I use the @abl macro from the octoprint terminal the @BEDLEVELVISUALIZER in the macro also doesn't work.

https://plugins.octoprint.org/plugins/bedlevelvisualizer/
https://github.com/jneilliii/OctoPrint-Bltouch

Jinja2 not accessing other plugins

I'm attempting to port some GCODE into a macro. My GCODE commands use Jinja2 to access values from other plugins. Works fine when I have the same GCODE in the Octoprint "GCODE Scripts" section but when I try to run my macro after defining it in GcodeMacros, it just doesn't run. I don't see any GCodeMacros log files and there's no terminal output when I try to run my macro.

M104 S{{ plugins.preheat.tool0|int() }} ;Heat nozzle
M109 S{{ plugins.preheat.tool0|int() }} ;Wait for nozzle
M702 ;Unload filament

[Feature Request] Parameterised Macros

I am wondering if parameterized macros may be cool.

It would be like this:

@command <params>

And available in the macro like

{{ param }}

I need to think of some example use-cases for this first, before developing it - let me know if you read this & think of something!

[Feature Request] Wait for and use response

Hi,

would it be possible to build in functionality to wait for a response and use the contents of that response.

For instance, when I send
G28 X0 Y0
my Creality3D Ender 5 Plus responds with
Recv: X:360.00 Y:360.00 Z:40.20 E:813.64 Count X:28800 Y:28800 Z:32160

Now, I would like to extract the first X and Y values and be able to halve them so I can center my nozzle on the plate

for example, do something like this:

G28 X0 Y0
{% wait_for "Recv:" | extract_key_value %}

This could then result in something like:

Recv: {
  'X1': 360.00,
  'Y1': 360.00,
  'Z1': 40.20,
  'E1': 813.64,
  'X2': 28800,
  'Y2': 28800,
  'Z2': 32160
}

Then I could use this to center the nozzle:

G0 X{% Recv.X1/-2 %} Y{% Recv.Y1/-2 %}

Install no longer works with python 3.12

The configparser package bundled with python 3.12 no longer contains a SafeConfigParser export that your plugin depends on. Because of that it (along with a few other plugins) can no longer get installed on python 3.12.

The issue occurs in versioneer.py (which I'm sure you copied from the template) which contains this reference to the now-removed export. Replacing that with configparser.ConfigParser() partially solved the issue for me. After that one more pops up. On the line after a file is opened and readfp is called. readfp doesn't exist anymore. Instead, simply parser.read(setup_cfg) is enough and fixes the issue.

I think there's maybe 2 ways to fix this:

  • Look at what octoprint itself did and maybe try to make that work with this plugin (see their commit)
  • Just replace those two lines and wrap them in a bunch of if-not-defined-then-other-thing try-catches. Would be happy to create a PR for the latter.

Jinja2 syntax

Hi all,

I'm trying to use Jinja2 syntax in the plugin.
I'm actually trying to set a macro saying if the bed temp is > than 27 please wait. I set this code but it's not working. Can you tell me where the mistake is?
Thanks

Code:
{% for n in range(100) %}
{% if bed_temperature[0] > 27 %}
G4 S60
{% endif %}
{% endfor %}

Conflict with Bed Visualizer?

Version 1.1.0 breaks Bed Visualizer.
FYI, Bed Visualizer uses a "macro" (@BEDLEVELVISUALIZER) for its operation.
I suspect a conflict.

execution of GCODE macro, does not take into account waiting for commands to finish

I am using the GCODE macro script to run an end-sequence of the job, ensuring cooling down, shutdown Pi and poweroff. Shutdown and poweroff are done by the Tasmota plugin and work (using the M81 gcode)..

I have the following GCODE when finishing (a single line):

@shutdown_power

Shutdown power is defined as follows (also a single line):

{% include "shutdown_tasmota.gcode" %}

The content of the gcode file is:

cat shutdown_tasmota.gcode

M117 Cooling down
;
M109 S50 ; wait for extruder temp (cooling)
M109 R50 ; wait for extruder temp (cooling)
G4 S1
;
M104 S0  ; turn off temperature

M117 Shutdown/poweroff

M81 MK3S 1
;======================= Stop printer

Strictly speaking only one M109 R50 is needed, but I used both just to be sure the firmware is not causing a problem.

The problem is that "M81 MK3S 1" is executed, without waiting for the printer to cooldown. It looks like it is "just" executing", but not waiting for the command to complete.

By contrast: if I add the M109 to the endcode, everything works, so whithout the scipt altered, these three lines work as a workaround:

M109 S50 ;
M109 R50 ;
@shutdown_power

ALSO: If I split the commands over TWO MACROS, it works:

@cooldown
@shutdown_power

It can be reproduced by having multiple M117 messages in a script: before and after heating / wait mode. The progress can be seen on the terminal comand: the M117 AFTER the M109 R50comes immediately. (also shown in the octoprint daskboard).

Using a prusa MK3S+, latest firmware 3.12.2
System bundle included.

octoprint-systeminfo-20230613195238.zip

In case you are wondering WHY I did this macro setup:

I can now even during the print replace the macro content, by just copying another file into it. Thus I can change the behaviour after a printjob finishes. The printer can either stay on, or do a controlled cooldown/shutdown/power off.

In order to conveniently swap the gcode, I placed both variant in the gcode directory and involke a cp command to copy the desired file over it, from a pulldown in the octoprint bar, using the plugin "system command editor". (For the menu where also the other power / reboot options are).

Sliced GCODE files, do not need ANY alteration: everything is done from octoprint settings and plugin configuration. The two workarounds work for me now, but the behaviour that "busy processing" responses from the printer are not considered, was troublesome to debug.

skipping the @?

Great Plugin that nearmost solves an old problem of mine. On toolchange there are special commands to be inserted depending on what tool is selected. Now I might add an @t1 in to the gcode to start that related marcro for tool 1 - but if T1 only could trigger that macro it would be much easier to swap slicer. Any chance to archive this?

[Feature Request] Macros stored as files

Due to Marlin's lack of M98 M99 support (subprogram start/end), I'm trying to do a workaround using macros. Your plugin is almost exactly what I need, except the length of my macro can't be input through the UI, and manually stuffing it in the config.yaml file seems... abusive.

Could there be a way to define macros as the content of another file? Or better still, can the macro just be a call to a separate gcode file (as uploaded through the octoprint sidebar)?

Jinja2 Rendering

Leaving this hear to request rendering like Octoprint scripts, using Jinja2 as directed.

Was from thread on Discord about trying to mimic conditional gcode from RRF to use random() function to generate random start point for primeline.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.