Postprocessor Popup input box

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:

Postprocessor Popup input box

Post 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,
User avatar
Les Newell
Site Admin
Posts: 3661
Joined: Thu May 11, 2006 8:12 pm

Re: Postprocessor Popup input box

Post 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.
David_Lelen01
Posts: 452
Joined: Wed Sep 12, 2018 8:18 pm
Location: South Carolina, USA
Contact:

Re: Postprocessor Popup input box

Post 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.
User avatar
Les Newell
Site Admin
Posts: 3661
Joined: Thu May 11, 2006 8:12 pm

Re: Postprocessor Popup input box

Post 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()
David_Lelen01
Posts: 452
Joined: Wed Sep 12, 2018 8:18 pm
Location: South Carolina, USA
Contact:

Re: Postprocessor Popup input box

Post 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
File Name Error.PNG (64.13 KiB) Viewed 633 times
User avatar
Les Newell
Site Admin
Posts: 3661
Joined: Thu May 11, 2006 8:12 pm

Re: Postprocessor Popup input box

Post 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()
David_Lelen01
Posts: 452
Joined: Wed Sep 12, 2018 8:18 pm
Location: South Carolina, USA
Contact:

Re: Postprocessor Popup input box

Post 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
User avatar
Les Newell
Site Admin
Posts: 3661
Joined: Thu May 11, 2006 8:12 pm

Re: Postprocessor Popup input box

Post by Les Newell »

Try

Code: Select all

   scamJobPath = sc.Parts:Get():GetFileName()
   scamJobName = wx.wxFileName(scamJobPath ):GetFullName()
David_Lelen01
Posts: 452
Joined: Wed Sep 12, 2018 8:18 pm
Location: South Carolina, USA
Contact:

Re: Postprocessor Popup input box

Post 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.
Post Reply