If anyone is interested in how this came out, here is my completed hack:
I added this function definition (from web search) to GCode.js
Code: Select all
//cjm Pulled this function from internet
// It builds date sting -> 2013/10/04 08:51:32
function getDateTime() {
var now = new Date();
var year = now.getFullYear();
var month = now.getMonth()+1;
var day = now.getDate();
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds();
if(month.toString().length == 1) {
var month = '0'+month;
}
if(day.toString().length == 1) {
var day = '0'+day;
}
if(hour.toString().length == 1) {
var hour = '0'+hour;
}
if(minute.toString().length == 1) {
var minute = '0'+minute;
}
if(second.toString().length == 1) {
var second = '0'+second;
}
var dateTime = year+'/'+month+'/'+day+' '+hour+':'+minute+':'+second;
return dateTime;
}
And I then made this modification to writeHeader
Code: Select all
GCode.prototype.writeHeader = function() {
//cjm add header lines to the GCode file
this.writeLine("(GCode generated by QCAD on " + getDateTime() + ")"); //Insert a comment in GCode file
this.writeLine("(Spindle ON/OFF added by this script)"); //Insert a comment in GCode file
this.writeRapidZMove(this.getSafetyZLevel());
this.toolPosition = GCode.ToolPosition.Clear;
};
The top of my resulting GCode looks like this:
Code: Select all
N10 (GCode generated by QCAD on 2014/03/29 07:32:25)
N20 (Spindle ON/OFF added by this script)
N30 G00 Z5
N40 ......
..........
I have additional hacks that add an M03 to start the spindle before the first cut and an M05 to stop it at end.
Now I need to go back and do it correctly, rather than changing GCode.js directly.