Custom Printer and Custom GCODE during G1 movements
 
Notifications
Clear all

Custom Printer and Custom GCODE during G1 movements  

  RSS
PrinterFella
(@printerfella)
New Member
Custom Printer and Custom GCODE during G1 movements

I have a custom Multi-Material printer. I want to run a macro half-way through a linear G1 movement. Here is an example of basically a rectangular infill and these are the last lines of code before a tool change. 

G1 X207.295 Y60.254 E.15855

G1 X92.705 Y60.254 E10.51369

G1 X92.705 Y58.526 E.15855

G1 X207.451 Y58.526 E10.52796;

LAYER_CHANGE;

Z:0.9;HEIGHT:0.3

G1 Z.9 F9000G1 E-5 F2400

M98 P"CustomMacro"

Basically the way my code is working now is that the custom macro is entered in the 'End G-Code' for that filament/tool head but I want the macro to be executed at the half way point of the last line being printed with that tool. So in the straight line where it goes from X92.705 to X207.451 I want the custom macro to be executed maybe 40mm from the X207.451 point, rather than once the printing is finished. 

 

Any help would be greatly appreciated thank you!

Posted : 12/12/2022 1:58 pm
Tim Weston
(@tim-weston)
Estimable Member
RE: Custom Printer and Custom GCODE during G1 movements

I'm happy to be proved wrong by someone with more knowledge, but I am pretty sure you can't get PrusaSlicer to do what you want here.

I think you will have to post-process the G-Code file to:

  • Find the G1 command where you want the custom code inserted.
  • Use the coordinates in the G1 command to calculate a new end-point based on the existing start/end-points and the new distance required (perhaps assume 50% of the current G1 distance).
  • Calculate the required E value for the new distance travelled.
  • Modify the G1 command with the new end-point and E value.
  • Insert your custom code after the modified G1 command.
  • Optionally add a further G1 command after your custom code to execute the remaining portion of the original G1 command to the original end-point (if that is what you need).

Hope that helps.

Cheers,

Tim

Posted : 13/12/2022 4:13 pm
Neophyl
(@neophyl)
Illustrious Member
RE: Custom Printer and Custom GCODE during G1 movements

I think Tim is correct.  I don't know of any other way except a post processing script either.  You could always enquire/raise an issue in the PS github where the devs are.  https://github.com/prusa3d/PrusaSlicer/issues  

Posted : 13/12/2022 4:27 pm
PrinterFella
(@printerfella)
New Member
Topic starter answered:
RE: Custom Printer and Custom GCODE during G1 movements

Thank you very much!

Posted : 31/01/2023 3:09 pm
Share: