Using post variable in on_init()

Having problems with or questions about SheetCam? Post them here.
Post Reply
rrc1962
Posts: 141
Joined: Sun Jan 17, 2010 4:55 pm

Using post variable in on_init()

Post by rrc1962 »

Les...

Is there any way I can use post variables in the on_init() function? They all seem to have a NIL value when called in on_init(). I want to post some job parameters in the program header. These parameters would be set in post variables. If not, is there another way I can post job info in the program header?

Thanks
User avatar
Les Newell
Site Admin
Posts: 3668
Joined: Thu May 11, 2006 8:12 pm

Post by Les Newell »

Is there any way I can use post variables in the on_init() function?
I am afraid not many are available at that pooint. Which parameters do you need? One trick to see what is available is to set a breakpoint in OnInit() then run the post. When it hits the breakpoint have a look at the global variables.
rrc1962
Posts: 141
Joined: Sun Jan 17, 2010 4:55 pm

Post by rrc1962 »

Les Newell wrote:
Is there any way I can use post variables in the on_init() function?
I am afraid not many are available at that pooint. Which parameters do you need? One trick to see what is available is to set a breakpoint in OnInit() then run the post. When it hits the breakpoint have a look at the global variables.
They are user defined variables that will change with each program. The only place I can put them where they only appear once in the program is in on_init(). Anywhere else and they end up posting numerous times through out the program.
User avatar
Les Newell
Site Admin
Posts: 3668
Joined: Thu May 11, 2006 8:12 pm

Post by Les Newell »

Are you using the variables in Options->job options->variables? If so you can access them in the post using the var global.
For example if you have defined a variable called 'myVariable' you could access it like this:
var.myVariable
Note you can only read variables in the post. If you write to them you wil not change the variable's value.
rrc1962
Posts: 141
Joined: Sun Jan 17, 2010 4:55 pm

Post by rrc1962 »

Les Newell wrote:Are you using the variables in Options->job options->variables? If so you can access them in the post using the var global.
For example if you have defined a variable called 'myVariable' you could access it like this:
var.myVariable
Note you can only read variables in the post. If you write to them you wil not change the variable's value.
That would work better. I tried adding some variables and set units as NONE because they are just numbers, like 40, 60, 0.20, etc. I eneter the value under value but when I close the dialog and re-open it, the value is gone. How do I set a variable value and make it stick?

Actually, the value disappears when I move the cursor out of the text box.

What I did was set up a bunch of Operation variables and set up a counter in the post so it only posts them once on the first OnPenDown(). That's working, but using job option variables would be much cleaner.

Thanks
rrc1962
Posts: 141
Joined: Sun Jan 17, 2010 4:55 pm

Post by rrc1962 »

I figured out by using the variable monitor that the variables are actually being set even though by looking at the variable definitions, it doesn't appear that way.

So the next question, since the user has to have the variable monitor open, is how do I get rid of the following three variables, which we don't ever use anyway....

-MaterialThickness
-RapidClearance
-ClampClearanceHeight

I'd like only the variables I define to show in variable monitor.
rrc1962
Posts: 141
Joined: Sun Jan 17, 2010 4:55 pm

Post by rrc1962 »

So after running a post, a whole bunch of other variables popped up. I'm guessing what I want to do....Just show my variables..... is not possible. Is there a way to make the variable value show with the variable definition under Options -> Job -> Variables? That would make it easy for the user to just work with the defined variables and not have to worry about all of the other system variables that appear in variable monitor.
User avatar
Les Newell
Site Admin
Posts: 3668
Joined: Thu May 11, 2006 8:12 pm

Post by Les Newell »

So the next question, since the user has to have the variable monitor open, is how do I get rid of the following three variables, which we don't ever use anyway....

-MaterialThickness
-RapidClearance
-ClampClearanceHeight
You can't remove these. They are generated within SheetCam. The variable monitor is meant more for debugging than production use.

The variables in job otions and application options should show the values. There is abviously a bug in there and I'll try to fix it for the next release.
Post Reply