ColorPrint by PRUSA3D fail
Hallo. I have a Prusa MK2s and i youse Slic3r 1.39.2+ to make my gcode on a MacBook. The gcode works fine but when I will chance the layer color using ColorPrint by PRUSA3D, the program fail. ColorPrint come up whit a error saying "Uncaught node.js Error" and "RangeError: Invalid string length". when I try to use colorPrint ind the wee browser the webpage just frees.
Can some one help?
- Rune
Re: ColorPrint by PRUSA3D fail
Rune, I can confirm. Maybe there is some GCODE line that the new version can't read or there is some special control character in the file that is tripping up the parsing?
Since I have no tools to debug the node.js app, I can't see whats going on.
I can't even find the Github repo to file an issue against.
Re: ColorPrint by PRUSA3D fail
Some more digging here.
De-minified the main.js in the app and re-ran it from command line. Same result, but now I have a real line # where the exception was thrown:
...
[35323:0606/201319:INFO:CONSOLE(65)] "Uncaught RangeError: Invalid string length", source: file:///Users/xxx/Applications/prusa3d_mac_2_1_6/ColorPrint%20by%20PRUSA3D.app/Contents/Resources/app.nw/js/main.js (65)
...
...
data.forEach(function(b) {
if (b.indexOf("G1 Z") >= 0) {
ObjectHeight = "";
for (a = 4; b[a] != " "; a++) {
ObjectHeight += b[a] // <-- Line 65
}
if (slic3r == 1) {
if (Layers.length == 0) {
Layers.push([(LineNumber + 1), ObjectHeight])
...
Looking at the GCode for the model, there are a lot of 'G1 Z' calls
G1 Z0.600 F15000.000
G1 Z0.200
G1 Z0.800 F15000.000
G1 Z0.200
G1 Z0.800 F15000.000
G1 Z0.200
G1 Z0.800 F15000.000
G1 Z0.200
G1 Z0.800 F15000.000
G1 Z0.200
G1 Z0.800 F15000.000
...
I'm guessing that we are just running off the end of the line and hence the invalid range error. Let me see if I can tweak the for loop to stop at the length as well.
Re: ColorPrint by PRUSA3D fail
Yes, sure enough, adding that extra loop conditional allowed the gcode to be processed quite quickly.
for (a = 4; b[a] != " " && a < b.length; a++) { // add && a < b.length
ObjectHeight += b[a]
}