Add custom tool variables
-
- Posts: 452
- Joined: Wed Sep 12, 2018 8:18 pm
- Location: South Carolina, USA
- Contact:
Add custom tool variables
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.
- Les Newell
- Site Admin
- Posts: 3687
- Joined: Thu May 11, 2006 8:12 pm
Re: Add custom tool variables
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.
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.
-
- Posts: 452
- Joined: Wed Sep 12, 2018 8:18 pm
- Location: South Carolina, USA
- Contact:
Re: Add custom tool variables
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.
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.
Re: Add custom tool variables
I have the same issue. I can't find any way to access the custom tool parameters anywhere in the post processor code.
Re: Add custom tool variables
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.
- Les Newell
- Site Admin
- Posts: 3687
- Joined: Thu May 11, 2006 8:12 pm
Re: Add custom tool variables
Try restarting SheetCam. Sometimes the variables don't appear until after you have restarted.
Re: Add custom tool variables
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.
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.
-
- Posts: 452
- Joined: Wed Sep 12, 2018 8:18 pm
- Location: South Carolina, USA
- Contact:
Re: Add custom tool variables
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 (41.5 KiB) Viewed 7300 times
-
- WaterjetCode.JPG (166.37 KiB) Viewed 7300 times
Re: Add custom tool variables
I don’t think you can see it until the OnToolChange() function is called. The tool is not set in OnInit()
-
- Posts: 452
- Joined: Wed Sep 12, 2018 8:18 pm
- Location: South Carolina, USA
- Contact:
Re: Add custom tool variables
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.
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.
- Les Newell
- Site Admin
- Posts: 3687
- Joined: Thu May 11, 2006 8:12 pm
Re: Add custom tool variables
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.
-
- Posts: 452
- Joined: Wed Sep 12, 2018 8:18 pm
- Location: South Carolina, USA
- Contact:
Re: Add custom tool variables
That actually makes sense, forgive me i was having a blonde moment haha
-
- Posts: 1
- Joined: Fri Sep 25, 2020 10:54 am
Re: Add custom tool variables
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.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.
thanks Sam
- Les Newell
- Site Admin
- Posts: 3687
- Joined: Thu May 11, 2006 8:12 pm
Re: Add custom tool variables
It goes in your post processor, outside of any function.