Add custom tool variables

Having problems with or questions about SheetCam? Post them here.
Post Reply
David_Lelen01
Posts: 452
Joined: Wed Sep 12, 2018 8:18 pm
Location: South Carolina, USA
Contact:

Add custom tool variables

Post by David_Lelen01 »

Is it possible to add custom variables to tool definitions in the tool table? Our waterjet machine has more variables that must be programmed than the default tool variables and I need a way to add these.
User avatar
Les Newell
Site Admin
Posts: 3660
Joined: Thu May 11, 2006 8:12 pm

Re: Add custom tool variables

Post by Les Newell »

Use DefineCustomToolParam:
post.DefineCustomToolParam("WaterTool", "Pump pressure", "pressure", sc.unit0DECPLACE, 40000, 20000, 60000)
This will create a new parameter called 'Pump pressure' in your waterjet tool definitions. It will have a default of 40000, a minimum of 20000 and a maximum of 60000. When that tool is selected you will have a new variable defined in the post processor called 'pressure'.

post.DefineCustomToolParam should be outside of any functions. I generally put it immediately after OnAbout but the exact placement is not important.
David_Lelen01
Posts: 452
Joined: Wed Sep 12, 2018 8:18 pm
Location: South Carolina, USA
Contact:

Re: Add custom tool variables

Post by David_Lelen01 »

That is exactly what i was looking for! Thank you Les!

EDIT:

Actually that is not working. It added the variable to the tool definition, but the post throws an error when it runs on the line where the new variable is.

I put: post.DefineCustomToolParam("WaterTool","ITC: Value Lo","ITCl",sc.unit2DECPLACE,0,0,500) in the post script outside of any function as you mentioned and then later in the code tried to call the variable ITCl by post.NonModalNumber("VA16=", ITCl, "0.##") and it threw an error. I tried to change it exactly you had mentioned before and used pressure for the variable and it still throws the error.
Jolbas
Posts: 88
Joined: Sat Feb 02, 2019 8:59 am

Re: Add custom tool variables

Post by Jolbas »

I have the same issue. I can't find any way to access the custom tool parameters anywhere in the post processor code.
Jolbas
Posts: 88
Joined: Sat Feb 02, 2019 8:59 am

Re: Add custom tool variables

Post by Jolbas »

The issue is still there in the 6.1.55 test version. The custom tool parameters appears in the tool dialog but are nil in the post processor as if they never are initiated.
User avatar
Les Newell
Site Admin
Posts: 3660
Joined: Thu May 11, 2006 8:12 pm

Re: Add custom tool variables

Post by Les Newell »

Try restarting SheetCam. Sometimes the variables don't appear until after you have restarted.
Jolbas
Posts: 88
Joined: Sat Feb 02, 2019 8:59 am

Re: Add custom tool variables

Post by Jolbas »

Yes!
After a lot of restarts renaming and resetting the values in the tool dialog it finally gave up and passed the parameters to the post processor. Not really sure what made it work.
David_Lelen01
Posts: 452
Joined: Wed Sep 12, 2018 8:18 pm
Location: South Carolina, USA
Contact:

Re: Add custom tool variables

Post by David_Lelen01 »

I finally had a chance to revisit this project and i am still unable to get the post processor to read the added variables. I have tried saving the default tool set a hundred times and closing and restarting the program, it just will not work. Attached are screenshots of what is happening. Hopefully you have an idea.
Attachments
WaterjetError.JPG
WaterjetError.JPG (41.5 KiB) Viewed 5072 times
WaterjetCode.JPG
WaterjetCode.JPG (166.37 KiB) Viewed 5072 times
Jolbas
Posts: 88
Joined: Sat Feb 02, 2019 8:59 am

Re: Add custom tool variables

Post by Jolbas »

I don’t think you can see it until the OnToolChange() function is called. The tool is not set in OnInit()
David_Lelen01
Posts: 452
Joined: Wed Sep 12, 2018 8:18 pm
Location: South Carolina, USA
Contact:

Re: Add custom tool variables

Post by David_Lelen01 »

I would think it should still be available to be called at any time though once the post is loaded. Perhaps not.

So that leads to the question, When is the tool set in sheetCAM? How could I make sure all the code i had in OnInit() is before any other code? Create another function and call it from OnInit()?

UPDATE: You were absolutely right! I moved all the code i was trying to write and simply put it under the function OnToolChange(). This shouldn't ever cause a problem because i wont be changing tools in the middle of a cut on the WaterJet anyways.
User avatar
Les Newell
Site Admin
Posts: 3660
Joined: Thu May 11, 2006 8:12 pm

Re: Add custom tool variables

Post by Les Newell »

The tool parameters are only available once the tool has been selected. They aren't available in OnInit() because at that point the post doesn't know what tools will be needed.
David_Lelen01
Posts: 452
Joined: Wed Sep 12, 2018 8:18 pm
Location: South Carolina, USA
Contact:

Re: Add custom tool variables

Post by David_Lelen01 »

That actually makes sense, forgive me i was having a blonde moment haha
Sam Plasma Cut
Posts: 1
Joined: Fri Sep 25, 2020 10:54 am

Re: Add custom tool variables

Post by Sam Plasma Cut »

Les Newell wrote: Fri Oct 12, 2018 10:41 am Use DefineCustomToolParam:
post.DefineCustomToolParam("WaterTool", "Pump pressure", "pressure", sc.unit0DECPLACE, 40000, 20000, 60000)
This will create a new parameter called 'Pump pressure' in your waterjet tool definitions. It will have a default of 40000, a minimum of 20000 and a maximum of 60000. When that tool is selected you will have a new variable defined in the post processor called 'pressure'.

post.DefineCustomToolParam should be outside of any functions. I generally put it immediately after OnAbout but the exact placement is not important.
I am working on a a project the needs custom tool paramitors and I beleive this code would be usefull however I cant seem to find were you inted for this code to be input.

thanks Sam
User avatar
Les Newell
Site Admin
Posts: 3660
Joined: Thu May 11, 2006 8:12 pm

Re: Add custom tool variables

Post by Les Newell »

It goes in your post processor, outside of any function.
Post Reply