CVH, I tried it once without result, but not knowing anything about javascript, I might have misplaced the block. But thanks a lot for your help.
Andrew, thanks for your support, this works. I understand that it does not describe the actual size, but knowing the envelope defines the minimum rectangle in which the object can be cut.
(I have a lot of small projects that all have a number in their filename but created on my laptop or in one of two desktops, with many revised cuts. It is messy, but now all .nc files are sucked up by a backend synology. And the goal is to sort them by project number and date)
include("LinuxCNCOffsetMM.js");
function MyLinuxCNCOffsetMM(cadDocumentInterface, camDocumentInterface) {
LinuxCNCOffsetMM.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.deltaX = 0;
this.deltaY = 0;
this.registerVariable("deltaX", "DELTA_X", false, "", "DEFAULT", "DEFAULT");
this.registerVariable("deltaY", "DELTA_Y", false, "", "DEFAULT", "DEFAULT");
this.header = [
"( [DATE_TIME] )",
"( Generated with: [INFILENAME])",
"( Tool diameter: [TD] mm )",
"( Cutting depth: [ZD] mm )",
"( Object envelope: X [DELTA_X], Y [DELTA_Y])"
];
}
MyLinuxCNCOffsetMM.prototype = new LinuxCNCOffsetMM();
MyLinuxCNCOffsetMM.displayName = "MyLinuxCNC (Offset) [mm]";
MyLinuxCNCOffsetMM.prototype.initExtents = function() {
// this initializes this.xMin, this.xMax, ...:
LinuxCNCOffsetMM.prototype.initExtents.call(this);
// now we can compute the sizes:
this.deltaX = this.xMax - this.xMin;
this.deltaY = this.yMax - this.yMin;
}
MyLinuxCNCOffsetMM.prototype.writeFile = function(fileName) {
// init date / time variable:
var today = new Date();
this.dateTime = formatDate(today, "dd/MMM/yyyy hh:mm:ss");
LinuxCNCOffsetMM.prototype.writeFile.call(this, fileName);
};
Result:
( Fri 22 May 2026 11:31:30 CEST )
( Generated with: test1.dxf)
( Tool diameter: 4 mm )
( Cutting depth: Z-4 mm )
( Object envelope: X 104, Y 94)
N10 G10 L1 P1 R2
N20 G0 Z10
etc…