Remove tool change code...

Having problems with or questions about SheetCam? Post them here.
Post Reply
Davek0974
Posts: 286
Joined: Sat Feb 01, 2014 2:07 pm

Remove tool change code...

Post by Davek0974 »

I'm using the standard Mach3 post processor and now have a semi-auto tool change routine built into Mach3.

I need to remove the tool change command for the FIRST tool in a job as this is carried out before the code is loaded.

Subsequent changes are fine.

i.e. the Post needs to assume the correct tool is loaded and set before the code runs.

Any ideas where i can alter the post for this???


Thanks
Davek0974
Posts: 286
Joined: Sat Feb 01, 2014 2:07 pm

Post by Davek0974 »

I've tried editing the post as i have done on my plasma but as soon as i touch it i get loads of errors?

I place this at the start..
post.DefineVariable ("FirstTool",-1)

My idea was to wrap the Toolchange event code in a If-Then block that says if FirstTool then do nothing but set first tool to false so next time round it runs ok.

But as soon as i place the define statement in, I get compile errors?

Can this post be edited?

Or have i missed a trick?
Davek0974
Posts: 286
Joined: Sat Feb 01, 2014 2:07 pm

Post by Davek0974 »

I think I have it, trial and error:)

post.DefineVariable (xxxx Needed to be in the OnInit() function


Then I just used a If-Then block to only allow the OnToolChange code to run if it has been skipped once already.

One anomaly is that the code generated has the spindle speed in it twice but that will not harm anything.
User avatar
Les Newell
Site Admin
Posts: 3668
Joined: Thu May 11, 2006 8:12 pm

Post by Les Newell »

Don't use DefineVariable. This is used to expose post processor variables to SheetCam. Any variable defined this way will appear in the 'Set post processor variable' operation.

Lua creates variables automatically the first time you use them. Here is how I would do it:
In function OnInit
FirstTool = true --this automatically creates the global variable 'FirstTool'

In OnToolChange
If FirstTool then
FirstTool = false
return
end

You get the extra S command because a tool change resets all modal g-codes.
Davek0974
Posts: 286
Joined: Sat Feb 01, 2014 2:07 pm

Post by Davek0974 »

Thanks Les, changes made, all working nicely ;)
Post Reply