/** Copyright (C) 2015-2018 by Autodesk, Inc. All rights reserved. $Revision: 41849 6d7e405464bb0f11c955ad97df850d057fefd042 $ $Date: 2018-02-14 14:11:32 $ FORKID {BD9FC5A6-277B-4D20-8FD5-7F70CC009C8D} */ description = "Epilog Laser"; vendor = "Epilog Laser"; vendorUrl = "https://www.epiloglaser.com"; legal = "Copyright (C) 2015-2018 by Autodesk, Inc."; certificationLevel = 2; longDescription = "Generic post for Epilog Laser. The post will output an HTML page with embedded SVG graphics which can then be printed using the installed Epilog Laser printer. " + "You can do both through-cutting and etching in the same program by enabling the 'useColorMapping' property. " + "When enabled, RED (255,0,0) will be used for through-cutting and GREEN (0,255,0) for etching. " + "You have to make sure to turn on color mapping and adjust the power settings correspondingly in the Epilog settings. " + "By default you will get BLUE (0,0,255) for both through-cutting and etching. " + "Enable the 'useWCS' property to force the part placement to match the WCS setting in the Setup. Otherwise the workpiece will be centered according to the given 'width' and 'height' properties. " + "Also keep in mind that you can choose the alignment of the workpiece in the print dialog (e.g. Top-Left corner)."; extension = "html"; mimetype = "text/html"; setCodePage("utf-8"); capabilities = CAPABILITY_JET; minimumCircularSweep = toRad(0.01); maximumCircularSweep = toRad(90); // avoid potential center calculation errors for CNC allowHelicalMoves = true; allowedCircularPlanes = (1 << PLANE_XY); // only XY arcs properties = { useWCS: true, // do not center the toolpath useTimeStamp: false, // enable to output a time stamp width: 48 * 25.4, // width in mm used when useWCS is disabled height: 24 * 25.4, // height in mm used when useWCS is disabled margin: 0, // margin in mm outputGuide: false, // output help geometry also useColorMapping: false, // use color mapping embedInHTML: true // enable to output SVG embedded in HTML }; // user-defined property definitions propertyDefinitions = { useWCS: {title:"Use WCS", description:"Do not center the toolpath.", type:"boolean"}, useTimeStamp: {title:"Use time stamp", description:"If enabled, a time stamp is outputted.", type:"boolean"}, width: {title:"Height(mm", description:"Height in mm, used when useWCS is disabled.", type:"number"}, height: {title:"Height(mm)", description:"Height in mm, used when useWCS is disabled.", type:"number"}, margin: {title:"Margin(mm)", description:"Sets the margin in mm.", type:"number"}, outputGuide: {title:"Output guide", description:"Enable to include help geometry.", type:"boolean"}, useColorMapping: {title:"Use color mapping", description:"Enable to use color mapping.", type:"boolean"}, embedInHTML: {title:"Embedded in HTML", description:"Enable to output SVG embedded in HTML.", type:"boolean"} }; var xyzFormat = createFormat({decimals:(unit == MM ? 3 : 4)}); // Recommended colors for color mapping. var RED = "rgb(255,0,0)"; var GREEN = "rgb(0,255,0)"; var BLUE = "rgb(0,0,255)"; var YELLOW = "rgb(255,255,0)"; var MAGENTA = "rgb(255,0,255)"; var CYAN = "rgb(0,255,255)"; /** Returns the given spatial value in MM. */ function toMM(value) { return value * ((unit == IN) ? 25.4 : 1); } function onOpen() { if (properties.embedInHTML) { writeln(""); writeln(""); writeln("" + (programName ? programName : localize("Unnamed")) + " - Autodesk CAM" + ""); writeln(""); writeln(""); if (properties.useTimeStamp) { var d = new Date(); writeln(""); } } else { writeln(""); } var WIDTH = 210; var HEIGHT = 297; if (properties.margin < 0) { error(localize("Margin must be 0 or positive.")); return; } var box = getWorkpiece(); var dx = toMM(box.upper.x - box.lower.x) + 2 * properties.margin; var dy = toMM(box.upper.y - box.lower.y) + 2 * properties.margin; log("Width: " + xyzFormat.format(dx)); log("Height: " + xyzFormat.format(dy)); var width = WIDTH; var height = HEIGHT; var useLandscape = false; if (properties.useWCS) { width = dx; height = dy; } else { if ((dx > width) || (dy > height)) { if ((dx <= height) && (dy <= width)) { useLandscape = true; width = HEIGHT; height = WIDTH; } } log("Sheet width: " + xyzFormat.format(width)); log("Sheet height: " + xyzFormat.format(height)); if (dx > width) { warning(localize("Toolpath exceeds sheet width.")); } if (dy > height) { warning(localize("Toolpath exceeds sheet height.")); } } writeln(""); // background // writeln(""); // invert y axis writeln(""); writeln(""); if (properties.useWCS) { // adjust for margin writeln(""); } else { // center on sheet writeln(""); } // we output in mm always so scale from inches xyzFormat = createFormat({decimals:(unit == MM ? 3 : 4), scale:(unit == MM) ? 1 : 25.4}); // workpiece // writeln(""); } function onComment(text) { } // From manual: Lines that you want to engrave rather than cut should be set .006" or greater. var cuttingWidth = 0.001 * 25.4; // make sure we do vector cutting - and not raster - from manual - max 0.03" var cuttingColor = BLUE; // color determines the cutting mode var guideWidth = 0.5; // make sure this gets ignored var guideColor = MAGENTA; // make sure this gets ignored function onSection() { switch (tool.type) { case TOOL_WATER_JET: // allow any way for Epilog warning(localize("Using waterjet cutter but allowing it anyway.")); break; case TOOL_LASER_CUTTER: break; case TOOL_PLASMA_CUTTER: // allow any way for Epilog warning(localize("Using plasma cutter but allowing it anyway.")); break; /* case TOOL_MARKER: // allow any way for Epilog warning(localize("Using marker but allowing it anyway.")); break; */ default: error(localize("The CNC does not support the required tool.")); return; } switch (currentSection.jetMode) { case JET_MODE_THROUGH: cuttingColor = properties.useColorMapping ? RED : BLUE; break; case JET_MODE_ETCHING: cuttingColor = properties.useColorMapping ? GREEN : BLUE; break; case JET_MODE_VAPORIZE: cuttingColor = properties.useColorMapping ? GREEN : BLUE; warning(localize("Using unsupported vaporization. Using etching instead.")); break; default: error(localize("Unsupported cutting mode.")); return; } var remaining = currentSection.workPlane; if (!isSameDirection(remaining.forward, new Vector(0, 0, 1))) { error(localize("Tool orientation is not supported.")); return; } setRotation(remaining); } function onParameter(name, value) { } function onDwell(seconds) { } function onCycle() { } function onCyclePoint(x, y, z) { } function onCycleEnd() { } function writeLine(x, y) { if (radiusCompensation != RADIUS_COMPENSATION_OFF) { error(localize("Compensation in control is not supported.")); return; } switch (movement) { case MOVEMENT_CUTTING: case MOVEMENT_REDUCED: case MOVEMENT_FINISH_CUTTING: break; case MOVEMENT_RAPID: case MOVEMENT_HIGH_FEED: case MOVEMENT_LEAD_IN: case MOVEMENT_LEAD_OUT: case MOVEMENT_LINK_TRANSITION: case MOVEMENT_LINK_DIRECT: default: return; // skip } var start = getCurrentPosition(); if ((xyzFormat.format(start.x) == xyzFormat.format(x)) && (xyzFormat.format(start.y) == xyzFormat.format(y))) { return; // ignore vertical } writeln(""); if (properties.outputGuide) { writeln(""); } } function onRapid(x, y, z) { writeLine(x, y); } function onLinear(x, y, z, feed) { writeLine(x, y); } function onRapid5D(x, y, z, dx, dy, dz) { onRapid(x, y, z); } function onLinear5D(x, y, z, dx, dy, dz, feed) { onLinear(x, y, z); } function onCircular(clockwise, cx, cy, cz, x, y, z, feed) { // linearize(tolerance); // return; if (radiusCompensation != RADIUS_COMPENSATION_OFF) { error(localize("Compensation in control is not supported.")); return; } switch (movement) { case MOVEMENT_CUTTING: case MOVEMENT_REDUCED: case MOVEMENT_FINISH_CUTTING: break; case MOVEMENT_RAPID: case MOVEMENT_HIGH_FEED: case MOVEMENT_LEAD_IN: case MOVEMENT_LEAD_OUT: case MOVEMENT_LINK_TRANSITION: case MOVEMENT_LINK_DIRECT: default: return; // skip } var start = getCurrentPosition(); var largeArc = (getCircularSweep() > Math.PI) ? 1 : 0; var sweepFlag = isClockwise() ? 0 : 1; var d = [ "M", xyzFormat.format(start.x), xyzFormat.format(start.y), "A", xyzFormat.format(getCircularRadius()), xyzFormat.format(getCircularRadius()), 0, largeArc, sweepFlag, xyzFormat.format(x), xyzFormat.format(y) ].join(" "); writeln(""); if (properties.outputGuide) { writeln(""); } } function onCommand() { } function onSectionEnd() { } function onClose() { writeln(""); writeln(""); writeln(""); writeln(""); if (properties.embedInHTML) { writeln(""); writeln(""); } }