Post processor issue - defining variables with an onParameter value

Post processor issue - defining variables with an onParameter value

max2KL2E
Explorer Explorer
251 Views
3 Replies
Message 1 of 4

Post processor issue - defining variables with an onParameter value

max2KL2E
Explorer
Explorer

Hello Guys,

 

I recently got around to writing a Siemens macro with my friend inspired by NYC CNC's video he uploaded a while ago on tool gauge length comparison, to help avoid collisions with incorrect tool table data.

 

For extra safety and some other things I'm working on, I am trying to define some new variables in my post processor with the parameters obtained from the dumper post processor, but anything I seem to try results in either an undefined value for my variable or an error stating that the parameter does not exist.

 

Please see the below screenshots further detailing my issue,

Test variable: (I expected it to be 5 like the dumper below, but its undefined)

Screenshot_61.png

Dumper post output:

Screenshot_63.png

Macro program: (for anyone interested)

Screenshot_62.png

 

I am sure I'm just doing something stupid, 

any advice would be greatly apperciated,

 

Thank you!

0 Likes
Accepted solutions (1)
252 Views
3 Replies
Replies (3)
Message 2 of 4

viacheslav.shapilov
Autodesk
Autodesk
Accepted solution

Hello, @max2KL2E.

Simplest way to get your parameter is to use getParameter function.

Something like this:

 

var holderClearance = getParameter("operation:holderClearance", 0 /* this is a default value, if clearance is not specified */);

 

But this function will work as expected only in onSection callback context. If you call it in global scope, or in onOpen it will return just default value.


Viacheslav Shapilov
Developer Technical Services
Autodesk Developer Network


Message 3 of 4

da_fish
Advocate
Advocate

Hi, Here is the format that I have used and works. This allows you to access the parameter through out the post.

var holderClearance;
function onParameter(name, value) {
  switch (name) {
  case "operation:holderClearance":
    holderClearance = value;
    break;
  default:
    break;
  }
}

You post may have an onParameter function already. If so, just add another case to the switch.

Message 4 of 4

max2KL2E
Explorer
Explorer

Thank you both for the help and examples!,

The issue was infact that I was not using it within onSection callback.

Everything is working excellent now.

0 Likes