What's new
What's new

My changes to the Fusion 360 post processor header comments if anyone is interested

F35Machinist

Cast Iron
Joined
Nov 3, 2021
Location
California
Below are my edits to the Fusion 360 post for comments in the header. I added the part name, setup, included more info in the tool list and formatted it for easier reading, added an operation list with the N word for each op since my brother can only jump to N words.

JavaScript:
function writeProgramHeader() {

  // dump machine configuration
  var vendor = machineConfiguration.getVendor();
  var model = machineConfiguration.getModel();
  var mDescription = machineConfiguration.getDescription();
  if (getProperty("writeMachine") && (vendor || model || mDescription)) {
    writeComment(localize("Machine"));
    if (vendor) {
      writeComment("  " + localize("vendor") + ": " + vendor);
    }
    if (model) {
      writeComment("  " + localize("model") + ": " + model);
    }
    if (mDescription) {
      writeComment("  " + localize("description") + ": "  + mDescription);
    }
  }
  writeComment(getGlobalParameter("document-path", ""));
  writeComment(getGlobalParameter("job-description", ""));
  writeln("");
  writeComment("Tool List")
  writeComment("------------------------------------------------------------------------------------------")
  // dump tool information
  if (getProperty("writeTools")) {
    if (false) { // set to true to use the post kernel version of the tool list
      writeToolTable(TOOL_NUMBER_COL);
    } else {
      var zRanges = {};
      if (is3D()) {
        var numberOfSections = getNumberOfSections();
        for (var i = 0; i < numberOfSections; ++i) {
          var section = getSection(i);
          var zRange = section.getGlobalZRange();
          var tool = section.getTool();
          if (zRanges[tool.number]) {
            zRanges[tool.number].expandToRange(zRange);
          } else {
            zRanges[tool.number] = zRange;
          }
        }
      }
      var tools = getToolTable();
      const top = xyzFormat.format(getWorkpiece().upper.getZ());

      for(var i=0;i < tools.getNumberOfTools(); i++){
        var tool = tools.getTool(i);
        var comment = "T" + toolFormat.format(tool.number) + " ";

        if([1, 15, 16].indexOf(tool.type) > -1)
        comment += tool.description + " ";

        if([9, 10, 11, 12, 13, 14].indexOf(tool.type) > -1)
        comment += tool.vendor + " " + tool.productId + " ";

        comment += getToolTypeName(tool.type) + " ";

        if([5,6,7,8].indexOf(tool.type) > -1)
        comment += tool.numberOfFlutes + "FLT ";

        comment = comment.replace(/[#()]/g, '');

        k = comment.length;
        for(var j=0; j< (40 - k); j++ )
        comment += " ";

        comment += tool.getHolderDescription() ;

        comment = comment.substring(0,59);

        k = comment.length;
        for(var j=0; j< (59 - k); j++ )
        comment += " ";

        comment += " FL=" +  spatialFormat.format(tool.fluteLength);

        comment += " SO=" +  spatialFormat.format(tool.bodyLength);

        writeComment(comment);

        comment = "    D=" + xyzFormat.format(tool.diameter);

        if(tool.taperAngle > 0 || tool.type == 7){
          k = comment.length;
          for(var j=0; j< (14 - k); j++ )
          comment += " ";
        }

        if(tool.taperAngle > 0)
          comment += "ANG=" + taperFormat.format(tool.taperAngle) + " ";

        if(tool.type == 7)
          comment += "CR=" + xyzFormat.format(tool.cornerRadius) + " ";

        if (zRanges[tool.number]) {
          k = comment.length;
          for(var j=0; j< (65 - k); j++ )
          comment += " ";

          comment += "ZDEPTH=" + spatialFormat.format(Math.abs(zRanges[tool.number].getMinimum() < 0 ? zRanges[tool.number].getMinimum() : (zRanges[tool.number].getMinimum() - top)));
        }

        writeComment(comment);
      };
    }
  }
  writeln("");
  if (getProperty("writeOperations")){
    writeComment("Operation List");
    writeComment("------------------------------------------------------------------------------------------")

    var numberOfSections = getNumberOfSections();
    var nseq = 0;
    for (var i = 0; i < numberOfSections; ++i) {
      var section = getSection(i);
      comment = "OP" + toolFormat.format(section.getId() +1) + " T" + toolFormat.format(section.getTool().number) + " ";

      if(getProperty("showSequenceNumbers") == "toolChange"){
        if(i == 0)
        comment += "N" + getProperty("sequenceNumberStart");
        else if(section.getTool().number != getSection(i-1).getTool().number)
        comment += "N" + (getProperty("sequenceNumberStart") + (getProperty("sequenceNumberIncrement") * ++nseq));

        k = comment.length;
        for(var j=0; j< (15 - k); j++ )
        comment += " ";

      }
      
      
      comment += section.getParameter("operation-comment").replace(/[()]/g, '');
      k = comment.length;
      for(var j=0; j< (50 - k); j++ )
      comment += " ";
      
      comment += " S=" + rpmFormat.format(section.getMaximumSpindleSpeed());
      k = comment.length;
      for(var j=0; j< (58 - k); j++ )
      comment += " ";

      comment += " F=" + rpmFormat.format(section.getMaximumFeedrate());
      k = comment.length;
      for(var j=0; j< (66 - k); j++ )
      comment += " ";

      if (is3D())
      comment += "ZDEPTH=" + spatialFormat.format(Math.abs(section.getGlobalZRange().getMinimum() < 0 ? section.getGlobalZRange().getMinimum() : (section.getGlobalZRange().getMinimum() - top)));

      writeComment(comment);
    }
    writeln("");
  }
 








 
Back
Top