Welcome! Log In Create A New Profile

Advanced

Converting Slic3r Gcode to suit EMC

Posted by emt 
emt
Converting Slic3r Gcode to suit EMC
January 10, 2012 12:21PM
Hi

I am keen to try Slic3r. I use EMC as control software so I us A instead of E for the extruder. I can use global edit in an editor to make changes but that can be time consuming. My experience of Linux is limited, can any one point me to a quicker way? Ideally a means of converting a number of files at once.


Regards

Ian
Re: Converting Slic3r Gcode to suit EMC
January 10, 2012 12:29PM
You probably missed the "Extrusion Axis" option in Slic3r. Just change E to A there.
emt
Re: Converting Slic3r Gcode to suit EMC
January 10, 2012 12:55PM
Many thanks.

I did miss that. Is there an easy way to change the g code file suffix?


Regards

Ian
fma
Re: Converting Slic3r Gcode to suit EMC
January 10, 2012 01:01PM
A better way is to let Slic3r use E as extruder - it will allow you to load gcode file in other tools (viewers) - and to write a filter. It will also convert from .gcode extension to .ngc. I use this filter:

#!/usr/bin/env python
# gcode2ngc.py

import sys


# First line
print "%"

f = file(sys.argv[1])
for line in f:
    print line.replace(" E", " U").strip()

# Last line
print "%"

To enable this filter, add the following code in the [FILTER] section of the .ini file:

PROGRAM_EXTENSION = .gcode Slicers Gcode file
gcode = /home/fma/emc2/configs/reprap/nc_files/gcode2ngc.py

put the python script in the nc_files directory (or any other directory, as long as you tell EMC2 where it is, through PROGRAM_PREFIX var in the [DISPLAY] section.


Frédéric
emt
Re: Converting Slic3r Gcode to suit EMC
January 11, 2012 10:50AM
Frédéric

Many thanks. That taught me a bit more about EMC2. How would you modify gcode2ngc.py to also replace all S with P?

I tried to guess the solution and ended up with duplicate lines.

Also the other line that causes me a syntax error in EMC gcode is the M82 generated by slic3r. At the moment I am editing the Gcode file and deleting it. How do you deal with that?


Regards

Ian
fma
Re: Converting Slic3r Gcode to suit EMC
January 11, 2012 01:11PM
Something like:

#!/usr/bin/env python
# gcode2ngc.py

import sys


# First line
print "%"

f = file(sys.argv[1])
for line in f:

    # Change extruder axis name
    line = line.replace(" E", " A")

    # S -> P
    line = line.replace(" S", " P")

    # Comment M82 code
    line = line.replace("M82", ";M82")

    print line.strip()

# Last line
print "%"

should work.


Frédéric
emt
Re: Converting Slic3r Gcode to suit EMC
January 12, 2012 10:31AM
Many thanks again Frédéric. That worked like a charm.


Regards

Ian
Greetings, gentlemen. I constructed a cnc and I have 2 drivers, and Linux cnc match. mastercamX5'm learning to machine parts. This program generates a. nc incompatible with asking linuxCNC files. ngc. could explain foolproof as applied, the filter system? I do not understand the amendment.

Greetings from Argentina
ezequiel
Sorry, only registered users may post in this forum.

Click here to login