Community
HSM Post Processor Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Cascade Post--Set-Up Sheet and Machine

20 REPLIES 20
SOLVED
Reply
Message 1 of 21
rbraddock
2732 Views, 20 Replies

Cascade Post--Set-Up Sheet and Machine

I'd like to set up my Process, so that when I post I get both the Excel 2017 Set-Up Sheet and the .nc code file for my machine. How do I go about starting this process, I have tweaked the Set Up Sheet and the HAAS ST-30 post processors to my liking, now I just need to figure out how to combine into a single posting process.

 

 

20 REPLIES 20
Message 2 of 21
AchimN
in reply to: rbraddock

There is basically no need to use cascading for that.

Please have a look into the generic haas.cps post and look for this code:

 

function onTerminate() {
  var outputPath = getOutputPath();
  var programFilename = FileSystem.getFilename(outputPath);
  var programSize = FileSystem.getFileSize(outputPath);
  var postPath = findFile("setup-sheet-excel-2007.cps");
  var intermdiatePath = FileSystem.replaceExtension(outputPath, "cnc");
  var a = "--property unit 0"; // use 0 for inch and 1 for mm
  if (programName) {
    a += " --property programName \"'" + programName + "'\"";
  }
  if (programComment) {
    a += " --property programComment \"'" + programComment + "'\"";
  }
  a += " --property programFilename \"'" + programFilename + "'\"";
  a += " --property programSize \"" + programSize + "\"";
  a += " --noeditor --log temp.log \"" + postPath + "\" \"" + intermdiatePath + "\" \"" + outputPath + ".xlsx\"";
  execute(getPostProcessorPath(), a, false, "");
}

You can add this function to your post processor and it should generate the desired setup sheet during post processing.

Make sure that the setup sheet post processor is located into the same folder as the post processor itself.

 

 



Achim.N
Principal Technology Consultant
Message 3 of 21
rbraddock
in reply to: AchimN

Thank you for the quick response. I've been using HSM for about a month now and often miss the obvious.

Message 4 of 21
rbraddock
in reply to: AchimN

I added the Code from the HAAS.cps post to the end of my_post.cps, which generates the nc code but does not trigger the set-up sheet. Am I missing a procedural call somewhere to the function onTerminate()?

 

I have verified that the excel.cps and setup sheet are in the same folder as the post.

 

Here is the last few functions from my post where I added at the end:

 

function onClose() {
writeln("");

optionalSection = false;

onCommand(COMMAND_COOLANT_OFF);

if (properties.gotChipConveyor) {
onCommand(COMMAND_STOP_CHIP_TRANSPORT);
}

if (getNumberOfSections() > 0) { // Retracting Z first causes safezone overtravel error to keep from crashing into subspindle. Z should already be retracted to and end of section.
var section = getSection(getNumberOfSections() - 1);
if ((section.getType() != TYPE_TURNING) && isSameDirection(section.workPlane.forward, new Vector(0, 0, 1))) {
writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(properties.g53HomePositionX), conditional(gotYAxis, "Y" + yFormat.format(properties.g53HomePositionY))); // retract
xOutput.reset();
yOutput.reset();
writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format((currentSection.spindle == SPINDLE_SECONDARY) ? properties.g53HomePositionSubZ : properties.g53HomePositionZ)); // retract
zOutput.reset();
writeBlock(getCode("STOP_LIVE_TOOL"));
} else {
if (gotYAxis) {
writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(properties.g53HomePositionY)); // retract
}
writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(properties.g53HomePositionX)); // retract
xOutput.reset();
yOutput.reset();
writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format(currentSection.spindle == SPINDLE_SECONDARY ? properties.g53HomePositionSubZ : properties.g53HomePositionZ)); // retract
zOutput.reset();
writeBlock(getCode("STOP_MAIN_SPINDLE"));
}
}

gMotionModal.reset();
cAxisEngageModal.reset();
writeBlock(getCode("DISENGAGE_C_AXIS"));

if (gotYAxis) {
writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(properties.g53HomePositionY));
yOutput.reset();
}

if (gotBarFeeder) {
writeln("");
writeComment(localize("Bar feed"));
writeBlock(mFormat.format(5));
// feed bar here
writeOptionalBlock(gFormat.format(105));
writeOptionalBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(properties.g53HomePositionX));
writeOptionalBlock(mFormat.format(1));
writeOptionalBlock(mFormat.format(99)); // restart
}

writeln("");
onImpliedCommand(COMMAND_END);
onImpliedCommand(COMMAND_STOP_SPINDLE);
if (true /*!properties.useM97*/) {
writeBlock(mFormat.format(30)); // stop program, spindle stop, coolant off
} else {
writeBlock(mFormat.format(99));
}
writeln("%");
}
// <<<<< INCLUDED FROM ../common/haas lathe.cps

properties.maximumSpindleSpeed = 3400;

gotYAxis = false;
yAxisMinimum = toPreciseUnit(gotYAxis ? -50.8 : 0, MM); // specifies the minimum range for the Y-axis
yAxisMaximum = toPreciseUnit(gotYAxis ? 50.8 : 0, MM); // specifies the maximum range for the Y-axis
xAxisMinimum = toPreciseUnit(0, MM); // specifies the maximum range for the X-axis (RADIUS MODE VALUE)
gotBAxis = false; // B-axis always requires customization to match the machine specific functions for doing rotations
gotMultiTurret = false; // specifies if the machine has several turrets

gotSecondarySpindle = false;
gotDoorControl = false;
gotBarFeeder = false;


function onTerminate() {
var outputPath = getOutputPath();
var programFilename = FileSystem.getFilename(outputPath);
var programSize = FileSystem.getFileSize(outputPath);
var postPath = findFile("setup-sheet-excel-2007.cps");
var intermdiatePath = FileSystem.replaceExtension(outputPath, "cnc");
var a = "--property unit 0"; // use 0 for inch and 1 for mm
if (programName) {
a += " --property programName \"'" + programName + "'\"";
}
if (programComment) {
a += " --property programComment \"'" + programComment + "'\"";
}
a += " --property programFilename \"'" + programFilename + "'\"";
a += " --property programSize \"" + programSize + "\"";
a += " --noeditor --log temp.log \"" + postPath + "\" \"" + intermdiatePath + "\" \"" + outputPath + ".xlsx\"";
execute(getPostProcessorPath(), a, false, "");
}

 

Message 5 of 21
rbraddock
in reply to: rbraddock

Here is the .cps file attached.

Message 6 of 21
AchimN
in reply to: rbraddock

Thanks for your feedback, just seen that the sample code does not support latest features.

Please use this code instead:

 

function onTerminate() {
  var outputPath = getOutputPath();
  var programFilename = FileSystem.getFilename(outputPath);
  var programSize = FileSystem.getFileSize(outputPath);
  var postPath = findFile("setup-sheet-excel-2007.cps");
  var intermdiatePath = getIntermediatePath();
  var a = "--property unit 0"; // use 0 for inch and 1 for mm
  if (programName) {
    a += " --property programName \"'" + programName + "'\"";
  }
  if (programComment) {
    a += " --property programComment \"'" + programComment + "'\"";
  }
  a += " --property programFilename \"'" + programFilename + "'\"";
  a += " --property programSize \"" + programSize + "\"";
  a += " --noeditor --log temp.log \"" + postPath + "\" \"" + intermdiatePath + "\" \"" + outputPath + ".xlsx\"";
  execute(getPostProcessorPath(), a, false, "");
}

Note that the post is looking for the

setup-sheet-excel-2007.cps

but you can change it to any other setup sheet of course.

 

The resulting setup sheet will be located into your nc output folder.

 

 

Please let me know if it works now on your end as well.



Achim.N
Principal Technology Consultant
Message 7 of 21
rbraddock
in reply to: AchimN

Added your code in at the end; still no dice. Attached is the .cps and an image of the folder/file structure.

 

 

 

 

EDIT: After looking more, I am getting an excel spreadsheet in the nc folder named "0001.nc.xlsx" rather than "0001.xlsx" and it does not contain the part image. I was waiting for Excel to open, like it had prior to when processed by itself. Is it possible to correct the filename?

Message 8 of 21
AchimN
in reply to: rbraddock

This should give you a better file name:

 

replace this:

  a += " --noeditor --log temp.log \"" + postPath + "\" \"" + intermdiatePath + "\" \"" + outputPath + ".xlsx\"";

with this:

 

  a += " --noeditor --log temp.log \"" + postPath + "\" \"" + intermdiatePath + "\" \"" + FileSystem.getFolderPath(outputPath) + "\\" + programName + ".xlsx\"";

 

 

The setup sheet gets generated in the background, if you like to have excel open it automatically please look into the setup-sheet-excel-2007.cps and change this last line:

 // executeNoWait("excel", "\"" + getOutputPath() + "\"", false, "");

to this:

executeNoWait("excel", "\"" + getOutputPath() + "\"", false, "");

 



Achim.N
Principal Technology Consultant
Message 9 of 21
rbraddock
in reply to: AchimN

That works, but still no picture. The excel post will generate the pic and place it in the set up sheet if called separately, but not in the combined post. I appreciate your time and patience with me.

Message 10 of 21
AchimN
in reply to: rbraddock

@rbraddock thanks for your feedback.

Issue is already fixed into the latest posts which will show up on the library shortly.

 

I did place the new code into your post processor, see attached.

I have attached the updated setup sheet as well.

 

Please try again with the new post + new setup sheet and provide feedback.

Thanks.



Achim.N
Principal Technology Consultant
Message 11 of 21
rbraddock
in reply to: AchimN

Uploaded the provided posts; thank you! The process is working with providing an image file in the set-up sheet and loading EXCEL. One point of note, though, if I remove the // from line 892  // executeNoWait("excel", "\"" + getOutputPath() + "\"", false, ""); as you suggested yesterday to launch EXCEL, you (at least I) end up cussing, because you get two instances of EXCEL triggered. Easy fix once I realized why you had it commented out. 🙂

 

Thank you very much for the assistance and the patience.

Message 12 of 21
AchimN
in reply to: rbraddock

This line is disabled by default into the generic setup sheet.

I´ve changed your Haas post which calls the setup sheet to open excel after it created the setup sheet.

So there is no need anymore to change anything into the setup sheet post itself, all handled by your haas post processor.

 

With the new sample code which is included into the generic haas.cps people can easily activate or copy/paste that code into any post and it will just work with the generic setup sheet.



Achim.N
Principal Technology Consultant
Message 13 of 21
rbraddock
in reply to: AchimN

@AchimN One last question if I may, is it possible to pass the Post Description, i.e. description = "HAAS SL-30T"; and Post Revision # of the post processor into the Excel processor as variables to be used? Something like this (in the Excel.cps) was what I was thinking:

programInfo["PostDescription"] = hasGlobalParameter("PostDescription") ? getGlobalParameter("PostDescription") : "";

programInfo["PostRevision"] = hasGlobalParameter("PostRevision") ? getGlobalParameter("PostRevision") : "";

Message 14 of 21
AchimN
in reply to: rbraddock

@rbraddock yes this is possible, you can pass that information to the setup sheet as well.

 

The code in onTerminate() into your haas post needs to get changed for that, this is the updated function: 

 

function onTerminate() {
  var outputPath = getOutputPath();
  var programFilename = FileSystem.getFilename(outputPath);
  var programSize = FileSystem.getFileSize(outputPath);
  var postPath = findFile("setup-sheet-excel-2007.cps");
  var intermediatePath = getIntermediatePath();
  var postDate = "";
  if ((typeof getHeaderDate == "function") && getHeaderDate()) {
    postDate = getHeaderDate();
  }
  var postVersion = "";
  if ((typeof getHeaderVersion == "function") && getHeaderVersion()) {
    postVersion = getHeaderVersion();
  }

  var a = "--property unit " + ((unit == IN) ? "0" : "1"); // use 0 for inch and 1 for mm
  if (programName) {
    a += " --property programName \"'" + programName + "'\"";
  }
  if (programComment) {
    a += " --property programComment \"'" + programComment + "'\"";
  }
  a += " --property programFilename \"'" + programFilename + "'\"";
  a += " --property programSize \"" + programSize + "\"";
  a += " --property " + "\"" + "postDescription" + "\"" + " " + "\"'" + description + "\"'";
  a += " --property " + "\"" + "postDate" + "\"" + " " + "\"'" + postDate + "\"'";
  a += " --property " + "\"" + "postVersion" + "\"" + " " + "\"'" + postVersion + "\"'";
  a += " --noeditor --log temp.log \"" + postPath + "\" \"" + intermediatePath + "\" \"" + FileSystem.replaceExtension(outputPath, "xlsx") + "\"";
  execute(getPostProcessorPath(), a, false, "");
  executeNoWait("excel", "\"" + FileSystem.replaceExtension(outputPath, "xlsx") + "\"", false, "");
}

It now passes the properties called "postDescription" , "postDate" and "postVersion" with the execute command.

 

You can get these new properties in you setup sheet post by using eg. properties.myPropertyName.

 

As a sample, this code pushes these properties to programInfo[ ]:

 

 

  programInfo["program.postDescription"] = properties.postDescription ? properties.postDescription : "undefined";
  programInfo["program.postDate"] = properties.postDate ? properties.postDate : "undefined";
  programInfo["program.postVersion"] = properties.postVersion ? properties.postVersion : "undefined";

 

Now you need to add this information into your setup sheet template:

 

modified setup-sheet-excel-2007-template.xlsxmodified setup-sheet-excel-2007-template.xlsx

 

 

 

Finally this will result into this setup sheet:

 

result.png

 

 

 

 

 

 



Achim.N
Principal Technology Consultant
Message 15 of 21
rbraddock
in reply to: AchimN

Fantastic! Thank you very much!

Message 16 of 21
rbraddock
in reply to: rbraddock

@AchimN I must have added the additional code above in the wrong location. Here is the output error I receive:

 

Error: Failed to evaluate post configuration.
Code page changed to '1252 (ANSI - Latin I)'
Start time: Monday, December 11, 2017 12:59:38 PM
Error(P:\!CNCProg\Posts\!haas SL-30.cps:3086): SyntaxError: illegal character
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Failed while processing global script.
Error: Syntax error: Missing end of literal at line 3086.

 

Here is the code from above as I added it to the onTerminate, I added the line numbers in BOLD COMMENTS

 

 

//3078// function onTerminate() {
//3079//   var postDate = "";
//3080//   if ((typeof getHeaderDate == "function") && getHeaderDate()) {
//3081//       postDate = getHeaderDate();
//3082//   }
//3083//   var postVersion = "";
//3084//   if ((typeof getHeaderVersion == "function") && getHeaderVersion()) {
//3085//      postVersion = getHeaderVersion();
//3086//   }" + "\"" + " " + "\"'" + revision + "\"'";
//3087//
//3088//   a += " --property " + "\"" + "postDescription" + "\"" + " " + "\"'" + description + "\"'";
//3089//   a += " --property " + "\"" + "postDate" + "\"" + " " + "\"'" + postDate + "\"'";
//3090//   a += " --property " + "\"" + "postVersion" + "\"" + " " + "\"'" + postVersion + "\"'";
//3091//   
//3092//   var outputPath = getOutputPath();
//3093//   var programFilename = FileSystem.getFilename(outputPath);
//3094//   var programSize = FileSystem.getFileSize(outputPath);
//3095//   var postPath = findFile("setup-sheet-excel-2007.cps");
//3096//   var intermediatePath = getIntermediatePath();
//3097//   var a = "--property unit " + ((unit == IN) ? "0" : "1"); // use 0 for inch and 1 for mm
//3098//   if (programName) {
//3099//   a += " --property programName \"'" + programName + "'\"";
//3100//   }
//3101//   if (programComment) {
//3102//   a += " --property programComment \"'" + programComment + "'\"";
//3103//   }
//3104//   a += " --property programFilename \"'" + programFilename + "'\"";
//3105//   a += " --property programSize \"" + programSize + "\"";
//3106//   a += " --noeditor --log temp.log \"" + postPath + "\" \"" + intermediatePath + "\" \"" + FileSystem.replaceExtension(outputPath, "xlsx") + "\"";
//3107//   execute(getPostProcessorPath(), a, false, "");
//3108//   executeNoWait("excel", "\"" + FileSystem.replaceExtension(outputPath, "xlsx") + "\"", false, "");
//3109//   }
 

 I believe my problem is with the end of if statement "}" being in the wrong location 

//3086//   }" + "\"" + " " + "\"'" + revision + "\"'";

I think line 3086 should be like this

//3086//   " + "\"" + " " + "\"'" + revision + "\"'";}

 Correct? NOPE!! I just tried that correction and it gives a different error on the same line "Missing end of literal"

 

So I will just await your reply.

Message 17 of 21
AchimN
in reply to: rbraddock

Copy/paste failed for whatever reason on my side, i´ve updated the sample code in my message above.



Achim.N
Principal Technology Consultant
Message 18 of 21
rbraddock
in reply to: AchimN

 


@AchimN wrote:

Copy/paste failed for whatever reason on my side, i´ve updated the sample code in my message above.


That fixed it. Thank you again for your assistance.

Message 19 of 21
emjdepauw
in reply to: AchimN

Thanks, I couldn't get the image working correctly. I've looked into the files you've attached, now it's working!

Message 20 of 21
shane_tully
in reply to: AchimN

How do i get the part image to save to the same folder as the setup sheet and by the same file name? It saves the image file in the folder specified under in the output folder in the post process dialog but if i hit post then change the folder and file name in the explorer dialog the image is saved in a different folder and different name then the setup sheet and and nc file.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report