Debug a post script.

Debug a post script.

cadTPLWJ
Advocate Advocate
1,433 Views
6 Replies
Message 1 of 7

Debug a post script.

cadTPLWJ
Advocate
Advocate

I wanted to streamline my workflow a little and try to autogenerate a HTML setup sheet everytime I "post" something.

Found this thread that seems promising post-calling-a-post

 

I have not nailed it yet. I get no setup sheet. I get no errors either.

 

In this thread I was advised to use log()  for debugging, but I cannot find out where the log entries goes.

 

https://forums.autodesk.com/t5/computer-aided-machining-cam/set-a-default-output-folder-for-quot-set...

 

How can I get my debugging going? (Scripts are attached)

0 Likes
1,434 Views
6 Replies
Replies (6)
Message 2 of 7

cadTPLWJ
Advocate
Advocate

Todays find.

setup_sheet.cps always generates a log file when run from Fusion 360 "Post Process".

my_linuxcnc.cps does not generate a log file. If I introduce a deliberate error in the script I get a log file.

 

Why is this?

 

 

function onTerminate() {
  var outputPath = getOutputPath();
  var programFilename = FileSystem.getFilename(outputPath);
  var programSize = FileSystem.getFileSize(outputPath);
  var postPath = findFile("setup-sheet.cps");
  var intermdiatePath = FileSystem.replaceExtension(outputPath, "ngc");
  var a = "--property unit 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 += " --noeditor --log temp.log \"" + postPath + "\" \"" + intermdiatePath + "\" \"" + outputPath + ".html\"";
  log(quote(getOutputPath()));
  log(getOutputPath());
  log(a);  
  execute(getPostProcessorPath(), a, false, "");
  A_Deliberate_bug();
}

Log file:

 

 

Information: Configuration: Modified LinuxCNC
Information: Vendor: LinuxCNC.org
Information: Posting intermediate data to 'E:\NGC\Parabol.ngc'
Information: Total number of warnings: 1
Error: Failed to post process. See below for details.
...
Code page changed to '1252  (ANSI - Latin I)'
Start time: Friday, March 31, 2017 2:50:32 PM
Code page changed to '20127 (US-ASCII)'
Post processor engine: 4.2.1 41304
Configuration path: C:\Users\Lars\AppData\Roaming\Autodesk\Fusion 360 CAM\Posts\my_linuxcnc.cps
Include paths: C:\Users\Lars\AppData\Roaming\Autodesk\Fusion 360 CAM\Posts
Configuration modification date: Friday, March 31, 2017 2:50:18 PM
Output path: E:\NGC\Parabol.ngc
Checksum of intermediate NC data: 160ac3cd324fe7c644c8ff52fa196f47
Checksum of configuration: 50b39548e7797423839e1d371e93b281
Vendor url: http://www.linuxcnc.org
Legal: Copyright (C) 2012-2015 by Autodesk, Inc.
Generated by: Fusion 360 CAM 2.0.2938
...
Warning: Work offset has not been specified. Using G54 as WCS.
Stop time: Friday, March 31, 2017 2:50:32 PM
"E:\\NGC\\Parabol.ngc"
E:\NGC\Parabol.ngc
--property unit 1 --property programName "'Parabol'" --property programComment "'ABS'" --property programFilename "'Parabol.ngc'" --property programSize "716456" --noeditor --log temp.log "C:\Users\Lars\AppData\Roaming\Autodesk\Fusion 360 CAM\Posts\setup-sheet.cps" "E:\NGC\Parabol.ngc" "E:\NGC\Parabol.ngc.html"
Error(C:\Users\Lars\AppData\Roaming\Autodesk\Fusion 360 CAM\Posts\my_linuxcnc.cps:1288): ReferenceError: A_Deliberate_bug is not defined
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Stack dump:
onTerminate()@C:\Users\Lars\AppData\Roaming\Autodesk\Fusion 360 CAM\Posts\my_linuxcnc.cps:1287

Failed while processing record 34711.
Error: Failed to invoke function 'onTerminate'.
Error: Failed to invoke 'onTerminate' in the post configuration.
Post processing failed.
0 Likes
Message 3 of 7

parobillard
Advocate
Advocate

I'm not sure what the question is but here some things for you

 

For debugging I use warning("some text here"); and error("some text here");

 

error(); WILL make the log aprear.

 

For the dual post Try this one

 

** note** you will need to modify it to your needs **

 

** EDITED there was error in the cps file ***

Message 4 of 7

parobillard
Advocate
Advocate

note: you will probably need to find:

setupArg += " \"--noeditor\"";

and replace it with:

//setupArg += " \"--noeditor\"";
Message 5 of 7

cadTPLWJ
Advocate
Advocate

Thanks for the help,

 

error() did force a log.

removing argument "--noeditor" did not give me a log. When I first saw that in your post, it looked like the obvious fix!

 

I will test your dual post script soon!

0 Likes
Message 6 of 7

parobillard
Advocate
Advocate

The noeditor thing was for my dual post.cps

 

If you don't comment it, the html file won't open automatically

0 Likes
Message 7 of 7

cadTPLWJ
Advocate
Advocate

I have now been working with POST for some time. After I got the default output for setup sheets fixed it has been quite workable.

 

But I never got this nice thing with one post script generating both G-code and a setup sheet working, my debug warning outputs only generates

   Post error code: 102

and no output files.

 

Code 102 is very general on its own and does not lead me anywhere.

 

What do I have wrong?

 

My modified dual-post script and a sample error log is attached.

0 Likes