additions to the header
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Indicate the post processor used.
Attach drawing files and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Indicate the post processor used.
Attach drawing files and screenshots.
Post one question per topic.
additions to the header
HI
Is it possible to add the "date & time" and "cutter dia." to the header?
Thanks
Jim
Is it possible to add the "date & time" and "cutter dia." to the header?
Thanks
Jim
Re: additions to the header
Opps it linux ubuntu 16.04 and qcadcam 3.17.1
Re: additions to the header
If you update to QCAD/CAM 3.17.2, you can use the following code (or similar) to output the date / time and tool diameter in the header:
The function formatDate supports various formatting parameters.
Code: Select all
include("GCodeBase.js");
function MyGCode(cadDocumentInterface, camDocumentInterface) {
GCodeBase.call(this, cadDocumentInterface, camDocumentInterface);
this.decimals = 4;
this.unit = RS.Millimeter;
// register variable for date and time:
this.dateTime = undefined;
this.registerVariable("dateTime", "DATE_TIME", true, "", 0);
this.header = [
"( date/time: [DATE_TIME] )",
"( tool dimater: [TD] )"
];
}
MyGCode.prototype = new GCodeBase();
MyGCode.displayName = "MyGCode";
MyGCode.prototype.writeFile = function(fileName) {
// init date / time variable:
var today = new Date();
this.dateTime = formatDate(today, "dd/MMM/yyyy hh:mm:ss");
GCodeBase.prototype.writeFile.call(this, fileName);
};
Re: additions to the header
Thanks Andrew
Now I just have to understand how to call this file.
Jim
Now I just have to understand how to call this file.
Jim
Re: additions to the header
That would be as follows:
- Save the attached ZIP file
- Extract the ZIP file
- Inside you can find a file called "MyGCode.js"
- Copy that file into the "postprocessors" directory of your QCAD/CAM installation (e.g. "/home/me/opt/qcadcam-3.17.2-pro-linux-x86_64/postprocessors")
MyGCode.js is a text file. You can edit it with any plain text editor of your choice (e.g. gedit).
- Save the attached ZIP file
- Extract the ZIP file
- Inside you can find a file called "MyGCode.js"
- Copy that file into the "postprocessors" directory of your QCAD/CAM installation (e.g. "/home/me/opt/qcadcam-3.17.2-pro-linux-x86_64/postprocessors")
MyGCode.js is a text file. You can edit it with any plain text editor of your choice (e.g. gedit).
- Attachments
-
- MyGCode.zip
- (541 Bytes) Downloaded 612 times
Re: additions to the header
Andrew
Ubuntu 16.04
qcadcam 3.17.2
Emc2IN.js
The cutter dia. TD worked as soon as I loaded 3.17.2 However adding the MyGCode.js didn't get DATE_TIME to work. So I changed the include statment at the top of Emc2.js to read 'include("MyGCode.js")' and it still is not working.
Any idea what I am doing wrong?
include("Emc2.js");
Thanks
Jim
Ubuntu 16.04
qcadcam 3.17.2
Emc2IN.js
The cutter dia. TD worked as soon as I loaded 3.17.2 However adding the MyGCode.js didn't get DATE_TIME to work. So I changed the include statment at the top of Emc2.js to read 'include("MyGCode.js")' and it still is not working.
Any idea what I am doing wrong?
include("Emc2.js");
Code: Select all
/**
* Configuration for EMC2 controllers.
* Output in Inches.
*/
function Emc2IN(cadDocumentInterface, camDocumentInterface) {
Emc2.call(this, cadDocumentInterface, camDocumentInterface);
this.unit = RS.Inch;
// G20: Inch
// G64 P#: Tolerance. Fine tune system for best compromise between speed and accuracy
this.header = [
"%",
"(FILE PATH [FILEPATH])",
"( date/time: [DATE_TIME] )",
"(CUTTER DIA. [TD])",
"G20",
"G64 P0.025"
];
}
Jim
Re: additions to the header
I would not recommend to directly change the configurations that come with QCAD/CAM (otherwise you might have to start over after every update).jamby wrote:The cutter dia. TD worked as soon as I loaded 3.17.2 However adding the MyGCode.js didn't get DATE_TIME to work. So I changed the include statment at the top of Emc2.js to read 'include("MyGCode.js")' and it still is not working.
Instead, you should always create your own configuration and derive it from an existing configuration. Typically, you would derive from the configuration that is closest to what you need (in your case, that seems to be Emc2.js). This way you are re-using everything in the base configuration (Emc2.js) but overriding some of the settings in your own configuration (MyGCode.js):
Code: Select all
include("Emc2.js");
function MyGCode(cadDocumentInterface, camDocumentInterface) {
Emc2.call(this, cadDocumentInterface, camDocumentInterface);
this.decimals = 4;
this.unit = RS.Millimeter;
// register variable for date and time:
this.dateTime = undefined;
this.registerVariable("dateTime", "DATE_TIME", true, "", 0);
this.header = [
"( date/time: [DATE_TIME] )",
"( tool dimater: [TD] )"
];
}
MyGCode.prototype = new Emc2();
MyGCode.displayName = "MyGCode";
MyGCode.prototype.writeFile = function(fileName) {
// init date / time variable:
var today = new Date();
this.dateTime = formatDate(today, "dd/MMM/yyyy hh:mm:ss");
Emc2.prototype.writeFile.call(this, fileName);
};
Re: additions to the header
Andrew
Then the correct usage of the "MyGCode.js" is to put a copy in the "postprocessor" subdirectory. And make no changes to any other files. Is that correct?
Sorry for my ignorance
Jim
Then the correct usage of the "MyGCode.js" is to put a copy in the "postprocessor" subdirectory. And make no changes to any other files. Is that correct?
Sorry for my ignorance
Jim
Re: additions to the header
Yes.jamby wrote:Then the correct usage of the "MyGCode.js" is to put a copy in the "postprocessor" subdirectory. And make no changes to any other files. Is that correct?
You might want to also rename MyGCode to something meaningful in both the file name and inside the file (class name).
Re: additions to the header
Andrew
I got most of the header working as I wanted but the "date/time" still eludes me.
Attached is a copy of the post-processor I edited.
Thanks
Jim
Yeah, I know its a kid with a new toy.
I got most of the header working as I wanted but the "date/time" still eludes me.
Attached is a copy of the post-processor I edited.
Thanks
Jim
Yeah, I know its a kid with a new toy.