Page 1 of 1
Postprocessor Popup input box
Posted: Tue Oct 20, 2020 12:26 pm
by David_Lelen01
Hey Les,
Is there a way to have the post pop up requesting the user to input a variable when the post is run. Like when I run the post, I want a popup to ask for the job name. We are having a problem with programmers not saving the job file and thus the job name doesn't get into the nc code. If I specifically ask for it, maybe it will increase the chance it will make it in there.
Thanks,
Re: Postprocessor Popup input box
Posted: Tue Oct 20, 2020 3:23 pm
by Les Newell
You can do that. Outside of any function add this:
Code: Select all
post.DefineCustomOption("Job name","jobName",sc.unitTEXT)
You will now have a variable 'jobName' that holds whatever text has been entered.
To show the options add this to function OnInit()
Code: Select all
post.ShowCustomOptions("Check job name")
Another option would be to add this to function OnInit()
Code: Select all
sc.wxActionManager.Get():Execute(sc.actSAVEAS_JOB)
That will do the equivalent of selecting
File->save job as when you run the post processor. You could also use actSAVE_JOB instead of actSAVEAS_JOB. That would just save the job without asking for a file name.
Re: Postprocessor Popup input box
Posted: Thu May 20, 2021 1:35 pm
by David_Lelen01
Hey Les, This has been working but I am getting complaints from some of our people that this added an unnecessary step. I can fix it, but i need some way for the post to get the sheetcam job name. Is there a variable for that? I see variables for partName, g code fileName and such, but i am not seeing one for the sheetcam job file name or file path.
Re: Postprocessor Popup input box
Posted: Fri May 21, 2021 9:42 am
by Les Newell
One option would be:
Code: Select all
sc.Parts:Get():AskSave("Save job")
This will only pop up a save dialog box if the job has changed since the last save/load.
If you want the job file name:
Code: Select all
local path = sc.Parts:Get():GetFileName()
This is the full path to the file.
If you want to extract the file name without path or extension:
Code: Select all
local fileName = wx.wxFileName(path):GetName()
If you want to extract the file name without path but with extension:
Code: Select all
local fileName = wx.wxFileName(path):GetFullName()
Re: Postprocessor Popup input box
Posted: Fri May 21, 2021 11:57 am
by David_Lelen01
Thanks Les! The full file path works fine. However, these two throws an error:
Code: Select all
local fileName = wx.wxFileName(path):GetName()
local fileName = wx.wxFileName(path):GetFullName()
- File Name Error.PNG (64.13 KiB) Viewed 650 times
Re: Postprocessor Popup input box
Posted: Fri May 21, 2021 12:02 pm
by Les Newell
Did you call sc.Parts:Get():GetFileName() first? For example:
Code: Select all
local path = sc.Parts:Get():GetFileName()
local fileName = wx.wxFileName(path):GetName()
Re: Postprocessor Popup input box
Posted: Fri May 21, 2021 12:18 pm
by David_Lelen01
Yep, here's the section of the post. Its inside the function OnInit()
Code: Select all
rapidX = 0
rapidY = 0
postFileName = fileNameOnly
scamJobPath = sc.Parts:Get():GetFileName()
scamJobName = wx.wxFileName(path):GetFullName()
initialized = 0
Re: Postprocessor Popup input box
Posted: Fri May 21, 2021 3:21 pm
by Les Newell
Try
Code: Select all
scamJobPath = sc.Parts:Get():GetFileName()
scamJobName = wx.wxFileName(scamJobPath ):GetFullName()
Re: Postprocessor Popup input box
Posted: Fri May 21, 2021 3:25 pm
by David_Lelen01
Oh i see whats happing now...... sorry, i'm such a rookie. That works perfect.
Thanks for all the help Les! Best customer service of anything i have ever purchased.