Triggering a macro by G-command
-
@bearer Thanks for the reply.
What I want is to call a macro file automatically only when a Z-lift is happening.
I'm not sure if that's possible. Maybe I have to look for a gcode editor to automatically find all Z-lifts of a certain tool and adding a macro call command, again not sure if that's possible.. -
@RajaaKahel By Z Lift, do you mean Z-Hop that is put in by the slic3r for travel moves? Depending on your slicer you may be able to modify it to add the macro call to every Z-Hop.
-
@rajaakahel said in Triggering a macro by G-command:
What I want is to call a macro file automatically only when a Z-lift is happening
That sounds like you're better off getting the slicer to do for you as Tony suggests or writing a script that parses the g-code before sending it to the Duet.
Maybe if you explain what the end goal is you may get some alternative suggestions on how to achieve it.
-
@bearer said in Triggering a macro by G-command:
In adittion any unkown G-code will try to execute a macro with the same name, not sure if it allows overriding existing code [...]
It won't. It only looks for macros with that name after it checked against the list of known ones and did not find a match.
-
@t3p3tony
Yes I mean Z-Hop. I use Simplify3D, do you know how I can do that? Do you know any slicer that can do that?
Thank you. -
@bearer Can you recommend me where to start reading to learn how to do that with with the gcode?
The goal is to run a servo that will cut a fiber line that is being printed from a special nozzle during Z-hop.
Thank you. -
Python or Perl are generic scripting languages.
You'd open the sliced file, and a new empty file, and read the sliced file line by line. For every line read look for Z and parse the numerical value, compare it to the last Z value.
If no Z value output the line to the new file.
If the Z value has decreased store the Z value and output the line to the new file
If the Z value has increased store the Z value and output the command(s) necessary to make the cut.
Close all files.I think that should do the trick. (unless you need the fiber not to be cut at layer changes, then you'd also need to look for hints from the slicer of layer changes, or maybe have different z-hop height to layer heights to be able to distinguish)
-
@bearer
Thank you. I'll see what I come up with. -
@rajaakahel
https://pastebin.com/JNF60tc5There are some links to help explain what it does, maybe it'll give you a rough idea of one possible solution.
(Disclaimer: I don't really write Perl code, so take it with a grain of salt..)
-
@bearer
Thank you! Will check it out.