Fusion Manufacture
Talk shop with the Fusion (formerly Fusion 360) Manufacture Community. Share tool strategies, tips, get advice and solve problems together with the best minds in the industry.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Trumpf 1030 Postprocessor JavaScript issue

Message 1 of 8
242 Views, 7 Replies

Trumpf 1030 Postprocessor JavaScript issue


Can anyone help with the Trumpf postprocessor? I would like to add a variable to get the sheet metal thickness based on stock thickness. (see picture below). I'm new to JavaScript so I need a little help with this.

Screenshot 2023-12-06 210507.jpg

It's not showing any errors in the script but when I run 'Start Debugging' I get a popup saying 'failed to read properties'

Screenshot 2023-12-06 211357.jpg

If I save it like this anyway then the post disappears from my post list in Fusion 360.


Note: I think it has something to do with the equation because if I input the value manually it works like expected. But then I did copy/paste the equation from somewhere else(which was part of a writeBlock and it is working fine for that) so I'm not sure what the problem is.

Message 2 of 8
in reply to: bow.enoch

In the first line you assign a string to the variable, because it includes parentheses.


Then in the if statement you try to use it for a mathematical comparison to a float. In JavaScript variables have no type, but it won't be able to convert the string to a number because of the parentheses. I would remove those and see how you go.

Message 3 of 8
in reply to: bow.enoch

To clarify, your first line should read like this:

var StockThickness = (Math.abs(getGlobalParameter("stock-upper-z") - getGlobalParameter("stock-lower-z")))


When you have the parentheses in quotes "(" and use + it concatenates into a string, so the thickness turns into text instead of a numerical value you can do maths with. This worked fine for the writeBlock where you got it from because it was outputting text.

Message 4 of 8
in reply to: matty.fuller

Hi @matty.fuller 

Thanks for the quick reply. I got it to work the way I want now, the parenthesis you mentioned were definitely a problem however I also had to move the variable and if statement into the function block where the PeirceSetSoft variable is being "used". (sorry I don't know what the proper term would be for that 😕 )

thanks, E

Message 5 of 8
in reply to: bow.enoch

This is a concept known as "scoping" and determines where variables can be declared and accessed within a program:

Message 6 of 8
in reply to: matty.fuller

Thanks for the information, although I still don't know why that couldn't've been a global variable. I think it has something to do with equation because if I put a number in manually it did work to have it global. (see pic.)

Screenshot 2023-12-07 204622.jpg

Message 7 of 8
in reply to: bow.enoch

I did a little experimentation and I think the reason you couldn't use it that way is likely because of when you tried to do so, due to the order of initialization.

I tried to access the parameter in the properties section and couldn't, then tried to use it in onOpen() and couldn't, but it works in onSection(). If you check the dumper post onOpen() is called first and THEN all of the parameters are declared. I think what you might want to do is look at using the onParameter() function to identify when these parameters are declared and use them there, rather than in every section.
Message 8 of 8
in reply to: matty.fuller

Hey @matty.fuller ,


Do you know of a way to hide some of the Class values based on the selection of Materialtype?

I've been trying with if statement without any luck.


Screenshot 2023-12-11 130719.jpg




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

Post to forums  

Autodesk Design & Make Report