Hello Guest it is September 18, 2021, 07:06:18 PM

### Author Topic: Switch to Another Work Offset When the G-Code is Loaded in Mach3  (Read 3123 times)

0 Members and 1 Guest are viewing this topic.

#### kvid

• 24
##### Re: Switch to Another Work Offset When the G-Code is Loaded in Mach3
« Reply #10 on: November 29, 2017, 11:25:43 AM »
Wow, that is so simple. It is a brilliant solution.

Would you mind sharing the code?

#### ger21

• 6,292
##### Re: Switch to Another Work Offset When the G-Code is Loaded in Mach3
« Reply #11 on: November 29, 2017, 11:39:11 AM »
Zero the axis first, then run this code.

Code: [Select]
`CurrentOffset = GetOEMDRO(46)  ' Get Current Coordinate system 1 = G54, 2 = G55, ....If CurrentOffset = 1 ThenZOffset=GetVar(5223)ElseIf CurrentOffset = 2 ThenZOffset=GetVar(5243)ElseIf CurrentOffset = 3 ThenZOffset=GetVar(5263)ElseIf CurrentOffset = 4 ThenZOffset=GetVar(5283)ElseIf CurrentOffset = 5 ThenZOffset=GetVar(5303)ElseIf CurrentOffset = 6 ThenZOffset=GetVar(5323)End IfFor X = 5223 To 5323 Step 20SetVar(X, ZOffset)Next XSleep(250)`
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html

#### BluePinnacle

• 305
##### Re: Switch to Another Work Offset When the G-Code is Loaded in Mach3
« Reply #12 on: November 29, 2017, 11:56:37 AM »
saved for later ^

#### Tweakie.CNC

• 8,798
• Super Kitty
##### Re: Switch to Another Work Offset When the G-Code is Loaded in Mach3
« Reply #13 on: November 30, 2017, 03:53:09 AM »
Quote
When I load G-Code DRO(46) contains G54 until I click Cycle Start and then Mach3 sets it to whatever work offset is in that G-Code. I run Auto Tool Zero script before I click Cycle Start.

It probably depends on which version of Mach3 you are running, however...

If your Gcode finishes with an M30 then the Offset and DRO(46) will be reset to G54 after the Gcode has been loaded (as you have discovered). Deleting the M30 from the Gcode will allow the DRO(46) to display the correct Gcode Offset for that particular file.

KEEP SAFE !

#### ger21

• 6,292
##### Re: Switch to Another Work Offset When the G-Code is Loaded in Mach3
« Reply #14 on: November 30, 2017, 06:28:26 AM »
Why would M30 change the offset?
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html

#### Tweakie.CNC

• 8,798
• Super Kitty
##### Re: Switch to Another Work Offset When the G-Code is Loaded in Mach3
« Reply #15 on: November 30, 2017, 09:21:52 AM »
Quote
Why would M30 change the offset?

Probably a question for Brian.

Try it and see...

As the Gcode loads and is read DRO(46) changes to the current offset then when the M30 is detected it reverts back to G54 - it will change to the current offset as soon as the Gcode is run (as discovered by Kvid).

But, as said, I am not certain this applies to all versions of Mach3.

KEEP SAFE !