1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | /** Copyright (C) 2015-2021 by Autodesk, Inc. All rights reserved. $Revision: 43470 147f5cf60e9217cf9c3365dc511a0f631d89bb16 $ $Date: 2021-10-13 20:53:32 $ FORKID {BD9FC5A6-277B-4D20-8FD5-7F70CC009C8D} */ description = "Epilog Laser" ; vendor = "Epilog Laser" ; legal = "Copyright (C) 2015-2021 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: { title : "Use WCS" , description: "Do not center the toolpath." , type : "boolean" , value : true , scope : "post" }, useTimeStamp: { title : "Use time stamp" , description: "If enabled, a time stamp is outputted." , type : "boolean" , value : false , scope : "post" }, width: { title : "Width(mm)" , description: "Width in mm, used when useWCS is disabled." , type : "number" , value : 1219.2, scope : "post" }, height: { title : "Height(mm)" , description: "Height in mm, used when useWCS is disabled." , type : "number" , value : 609.6, scope : "post" }, margin: { title : "Margin(mm)" , description: "Sets the margin in mm." , type : "number" , value : 0, scope : "post" }, outputGuide: { title : "Output guide" , description: "Enable to include help geometry." , type : "boolean" , value : false , scope : "post" }, useColorMapping: { title : "Use color mapping" , description: "Enable to use color mapping." , type : "boolean" , value : false , scope : "post" }, embedInHTML: { title : "Embedded in HTML" , description: "Enable to output SVG embedded in HTML." , type : "boolean" , value : true , scope : "post" } }; 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 (getProperty( "embedInHTML" )) { writeln( "" ); writeln( "" ); writeln( "<title>" + (programName ? programName : localize( "Unnamed" )) + " - Autodesk CAM" + "</title>" ); writeln( "" ); if (getProperty( "useTimeStamp" )) { var d = new Date(); writeln( "<!-- " + (d.getTime() * 1000) + " -->" ); } } else { writeln( "<!--?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?-->" ); } var WIDTH = 210; var HEIGHT = 297; if (getProperty( "margin" ) < 0) { error(localize( "Margin must be 0 or positive." )); return ; } var box = getWorkpiece(); var dx = toMM(box.upper.x - box.lower.x) + 2 * getProperty( "margin" ); var dy = toMM(box.upper.y - box.lower.y) + 2 * getProperty( "margin" ); log( "Width: " + xyzFormat.format(dx)); log( "Height: " + xyzFormat.format(dy)); var width = WIDTH; var height = HEIGHT; var useLandscape = false ; if (getProperty( "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( "<svg xmlns=" \"http: //www.w3.org/2000/svg\"" width="\""" +="" xyzformat.format(width)="" "mm\"="" height="\""" xyzformat.format(height)="" viewBox="\"0" 0="" "="" "\"="">"); // background // writeln("<rect x="\""" +="" xyzformat.format(0)="" "\"="" y="\""" width="\""" xyzformat.format(width)="" height="\""" xyzformat.format(height)="" style="\"fill:magenta;stroke:black;stroke-width:0.25;fill-opacity:0.01;stroke-opacity:0.25\"/">"); // invert y axis writeln( "<g transform=" \"translate(" " +=" " xyzformat.format(0)=" " " ,= "" "=" " xyzformat.format(height)=" " " )\ "=" ">" ); writeln( "<g transform=" \"scale(1, " -1)\"=" ">" ); if (getProperty( "useWCS" )) { // adjust for margin writeln( "<g transform=" \"translate(" " +=" " xyzformat.format(-tomm(box.lower.x)=" " getproperty(" margin "))=" " " ,= "" "=" " xyzformat.format(-tomm(box.lower.y)=" " " )\ "=" ">" ); } else { // center on sheet writeln( "<g transform=" \"translate(" " +=" " xyzformat.format(-tomm(box.lower.x)=" " (width=" " -=" " dx)=" " 2)=" " " ,= "" "=" " xyzformat.format(-tomm(box.lower.y)=" " (height=" " dy)=" " " )\ "=" ">" ); } // we output in mm always so scale from inches xyzFormat = createFormat({decimals:(unit == MM ? 3 : 4), scale:(unit == MM) ? 1 : 25.4}); // workpiece // writeln("<rect x="\""" +="" xyzformat.format(box.lower.x)="" "\"="" y="\""" xyzformat.format(box.lower.y)="" width="\""" xyzformat.format(box.upper.x="" -="" box.lower.x)="" height="\""" xyzformat.format(box.upper.y="" box.lower.y)="" style="\"fill:green;stroke:black;stroke-width:0.25;fill-opacity:0.1;stroke-opacity:0.25\"/">"); } 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 = getProperty( "useColorMapping" ) ? RED : BLUE; break ; case JET_MODE_ETCHING: cuttingColor = getProperty( "useColorMapping" ) ? GREEN : BLUE; break ; case JET_MODE_VAPORIZE: cuttingColor = getProperty( "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( "<line x1=" \"" " +=" " xyzformat.format(start.x)=" " " \ "=" " y1=" \"" " xyzformat.format(start.y)=" " x2=" \"" " xyzformat.format(x)=" " y2=" \"" " xyzformat.format(y)=" " fill=" \"none\" " stroke=" \"" " cuttingcolor=" " stroke-width=" \"" " cuttingwidth=" "></line>" ); if (getProperty( "outputGuide" )) { writeln( "<line x1=" \"" " +=" " xyzformat.format(start.x)=" " " \ "=" " y1=" \"" " xyzformat.format(start.y)=" " x2=" \"" " xyzformat.format(x)=" " y2=" \"" " xyzformat.format(y)=" " fill=" \"none\" " stroke=" \"" " guidecolor=" " stroke-width=" \"" " guidewidth=" "></line>" ); } } 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) { onExpandedRapid(x, y, z); } function onLinear5D(x, y, z, dx, dy, dz, feed) { onExpandedLinear(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( "<path d=" \"" " +=" " " \ "=" " fill=" \"none\" " stroke=" \"" " cuttingcolor=" " stroke-width=" \"" " cuttingwidth=" "></path>" ); if (getProperty( "outputGuide" )) { writeln( "<path d=" \"" " +=" " " \ "=" " fill=" \"none\" " stroke=" \"" " guidecolor=" " stroke-width=" \"" " guidewidth=" "></path>" ); } } function onCommand() { } function onSectionEnd() { } function onClose() { writeln( "</rect></g>" ); writeln( "</g>" ); writeln( "</g>" ); writeln( "</g></rect></svg>" ); if (getProperty( "embedInHTML" )) { writeln( "" ); writeln( "" ); } } function setProperty(property, value) { properties[property].current = value; } |