I really like Cura for some prints, but I found it quite annoying that it doesn't replace the filament usage tags properly in its G-code output files. For that reason I decided to look at its internals to fix it until a new Cura version is released. With my latest firmware
0.89f, the filament usage is read from both the beginning and the end of a G-code file, so the print progress on the Ormerod web control can be ultilized again. To get this working, you'll have to do the following three steps:
Step 1:
- Go to your Cura installation directory and open the file "Cura\gui\sceneView.py" with your favorite text editor (I use Notepad++)
- Search for "def _saveGCode" and insert the following bold line below the "else:" clause:
else:
profile.replaceGCodeTagsFromSlicer(targetFilename, self._engine.getResult())
if ejectDrive:
- Please make sure the indentation is properly aligned, since Python is quite sensitive about this. If it's wrong, this fix may not work for you.
Step 2:
- Open "Cura\util\profile.py" and search for "def replaceGCodeTagsFromSlicer"
- Replace the second line containing "data = data.replace" with the bold one, so the method looks like this:
data = data.replace('#P_TIME#', ('%8.2f' % (int(slicerInt._printTimeSeconds)))[-8:])
data = data.replace('#F_AMNT#', ('%7.1fm' % (slicerInt._filamentMM[0]))[-8:])
data = data.replace('#F_WGHT#', ('%8.2f' % (float(slicerInt.getFilamentWeight()) * 1000))[-8:])
- Note: This modification makes Cura output the filament usage in mm, although meters are default for Cura. It doesn't really matter though, because dc42's and my fork are smart enough to detect whether mm or meters are used.
Step 3:
- Adjust your Cura start G-code. I haven't really changed the first few lines, but I can confirm the following start G-code is working with my firmware fork:
;Sliced at: {day} {date} {time}
;Basic settings: Layer height: {layer_height} Walls: {wall_thickness} Fill: {fill_density}
;Print time: {print_time}
;Filament used: {filament_amount}m {filament_weight}g
;Filament cost: {filament_cost}
T1; Select extruder 1
M82; Use absolute distances for extrusion
M140 S{print_bed_temperature}; Set bed temperature
G1 X0 Y50 F3000; Go to wait for warm position
M116; Wait for all temperatures
M104 S{print_temperature}; Set extruder temperature
M116; Wait for all temperatures
- Just don't try to put the filament usage tags into the end G-code, because Cura's replace method only seems to modify the beginning of its output files
I saw dc42 has already reported this issue on Cura's GitHub site, but the developers denied to fix for this issue, so I'm posting a temporary solution here. I hope this helps!
Edited 1 time(s). Last edit at 08/27/2014 10:44AM by zombiepantslol.