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
/**
  Copyright (C) 2012-2018 by Autodesk, Inc.
  All rights reserved.
 
  XY post processor configuration.
 
  $Revision: 43470 147f5cf60e9217cf9c3365dc511a0f631d89bb16 $
  $Date: 2021-10-13 20:53:32 $
 
  FORKID {C649AECE-90C4-426b-92A7-8CA8B694CEF0}
*/
 
description = "XY";
vendor = "Autodesk";
legal = "Copyright (C) 2012-2018 by Autodesk, Inc.";
certificationLevel = 2;
minimumRevision = 24000;
 
longDescription = "Simple post to export toolpath in CSV format as 2D coordinates.";
 
extension = "csv";
setCodePage("ascii");
 
capabilities = CAPABILITY_MILLING;
tolerance = spatial(0.002, MM);
 
// user-defined properties
properties = {
};
 
var xyzFormat = createFormat({decimals:(unit == MM ? 3 : 4)});
 
var xOutput = createVariable({force:true}, xyzFormat);
var yOutput = createVariable({force:true}, xyzFormat);
var zOutput = createVariable({force:true}, xyzFormat);
 
/**
  Writes the specified block.
*/
function writeBlock() {
  writeWords(arguments);
}
 
/**
  Output a comment.
*/
function writeComment(text) {
  // writeln("# " + text);
}
 
function onOpen() {
  setWordSeparator(";");
 
  if (programName) {
    writeComment(programName);
  }
  if (programComment) {
    writeComment(programComment);
  }
 
  switch (unit) {
  case IN:
    writeComment("Inches");
    break;
  case MM:
    writeComment("Millimeters");
    break;
  }
}
 
function onComment(message) {
  writeComment(message);
}
 
function onSection() {
  { // pure 3D
    var remaining = currentSection.workPlane;
    if (!isSameDirection(remaining.forward, new Vector(0, 0, 1))) {
      error(localize("Tool orientation is not supported."));
      return;
    }
    setRotation(remaining);
  }
 
  // writeln("");
}
 
function onRadiusCompensation() {
  switch (radiusCompensation) {
  case RADIUS_COMPENSATION_LEFT:
  case RADIUS_COMPENSATION_RIGHT:
    error(localize("Radius compensation is not supported."));
    break;
  }
}
 
function onRapid(_x, _y, _z) {
  var x = xOutput.format(_x);
  var y = yOutput.format(_y);
  var z = zOutput.format(_z);
  /*
  if (x && y && z) {
    error(localize("XYZ motion is not supported."));
    return;
  }
  */
  if (x || y) {
    writeBlock(x, y);
  }
}
 
function onLinear(x, y, z, feed) {
  onExpandedRapid(x, y, z);
}
 
function onCommand(command) {
}