1

**General Mach Discussion / Modifying an old Mach3 macro to engrave sequential serial numbers**

« **on:**June 19, 2017, 03:32:37 PM »

I have a little project where I need to engrave serial numbers on about 200 pieces. I found this old post in another area of the forum and this macro sort of does the trick. I started to modify it to get it to work the way I wanted but ran into trouble with some of the deprecated commands. It would be pretty helpful if I could get it to work as I can call the macro as part of a larger program to get the serial number on the part.

The macro is attempting to set each of these variables to the current X and Y axis DRO readouts. This doesn't work and I think the 'getdro' command is obsolete. Plus I think the syntax is wrong anyway.

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

Here is the original topic:

https://www.machsupport.com/forum/index.php/topic,11018.0.html

What I really need help with is what is the proper syntax to define a new variable, then set the variable to the current X axis DRO (and similar for the Y axis)? I played with the getOEMdro() command but I don't understand the syntax and how you would turn that dro reading into something that can be used as an integer. I'm not much of a programmer so the syntax and logic is a bit tough for me to figure out. I'd greatly appreciate any advice or alternative options!

The macro is attempting to set each of these variables to the current X and Y axis DRO readouts. This doesn't work and I think the 'getdro' command is obsolete. Plus I think the syntax is wrong anyway.

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

Here is the original topic:

https://www.machsupport.com/forum/index.php/topic,11018.0.html

What I really need help with is what is the proper syntax to define a new variable, then set the variable to the current X axis DRO (and similar for the Y axis)? I played with the getOEMdro() command but I don't understand the syntax and how you would turn that dro reading into something that can be used as an integer. I'm not much of a programmer so the syntax and logic is a bit tough for me to figure out. I'd greatly appreciate any advice or alternative options!

Code: [Select]

`It wil start off by engraving S/N: then adds the serial number IE: S/N: 090300001 , next run S/N: 090300002 , ETC`

CODE EXAMPLE:

' Macro for consecutive S/N engraving from MACH

Sub main

Dim A As String

Dim Ch As String

Dim Cnt As Integer

SetVar(1303 , .250) 'LetterSpacing

Setvar(1300 , -0.005) ' Z Depth cutting

Setvar(1200 , 0.050) ' Safe Z

'CPx= Getoemdro(0)

'CPy= Getoemdro(1)

SETIJMODE(1)

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

message "S"

Code "g90 G0 Z#1200 X[#1301 + .2250] Y#1302 "

code "G91G0 x -.0706"

code " y-.0449"

code "G90 G1Z#1300 F20."

code "g91 g1X.0159Y-.0361I.05J.0004"

code "X.0375Y-.0151I.0377J.0395"

code "G1X.0348"

code "G3X.0373Y.0151I-.0001J.0539"

code "X.0157Y.0361I-.0346J.0365"

code "X-.016Y.0383I-.0551J-.0004"

code "X-.037Y.0164I-.0378J-.0356"

code "G1X-.0352"

code "G2X-.0373Y.0157I.0003J.0528"

code "X-.0157Y.0372I.0371J.0376"

code "X.0157Y.0374I.0535J-.0004"

code "X.0373Y.016I.0377J-.0365"

code "G1X.0706"

code "G90 G0Z[#1200]"

Code "G0 Z#1200 X[#1301 + .2250] Y#1302 "

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

While IsMoving()

Wend

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

message "/"

Code "G0 Z#1200 X[#1301 + .2250] Y#1302 "

code "G91G0X.0357Y.1071"

code "G90 G1Z#1300 F20."

code "G91 g1X-.1071Y-.2142"

code "G90 G0Z[#1200]"

Code "G0 Z#1200 X[#1301 + .2250] Y#1302 "

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

While IsMoving()

Wend

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

message "N"

Code "G90 g0 X[#1301 + .2250] Y#1302 "

code "G91G0X-.0706 Y-.1078"

code "G90 G1Z#1300 F20."

code "G91 g1y.2156"

code "x.1412 Y-.2156"

code "y.2156"

code "G90 G0 Z#1200"

Code "G0 Z#1200X[#1301 + .2250] Y#1302"

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

While IsMoving()

Wend

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

message ":"

Code "G90 g0 X[#1301 + .2250] Y#1302 "

code "G91G0y-.0559"

code "G90 G1Z[#1300 -.010] F20."

Code "Z#1200"

code "G91 Y.1118"

code "G90 G1Z[#1300 -.010] F20."

Code "Z#1200"

Code "G0 Z#1200X[#1301 + .2250] Y#1302"

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

While IsMoving()

Wend

P10= GetOEMDRO(1050)

A=Str(P10)

For Cnt=1 To Len(A)

Ch=Mid(A,Cnt,1)

Select Case Ch

Case "0" ZERO

Case "1" ONE

Case "2" TWO

Case "3" THREE

Case "4" FOUR

Case "5" FIVE

Case "6" SIX

Case "7" SEVEN

Case "8" EIGHT

Case "9" NINE

End Select

Next

P10=P10+1

SetOEMDRO(1050,P10)

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

SETIJMODE(1)

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

While IsMoving()

Wend

End Sub

Sub ZERO

message "Zero"

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

Code " G0 X[#1301 + .2250] Y#1302 "

code "G90 G0 z#1200"

code "G91 G0 X-.0004Y.1076"

code "G90 G1 Z#1300 F20."

code "G91 G1X.0176 "

code "G2X.0374Y-.0194I-.0021J-.05"

code "X.0164Y-.0417I-.0488J-.0432"

code "G1X-.0009Y-.1012"

code "G2X-.0157Y-.0372I-.0527J.0004"

code "X-.0372Y-.0157I-.0375J.0371"

code "G1X-.0353"

code "G2X-.0372Y.0157I.0004J.0528"

code "X-.0157Y.0372I.0371J.0376"

code "G1Y.1059"

code "G2X.0157Y.0389I.0585J-.001"

code "X.0372Y.0175I.0382J-.033"

code "G1X.0177 "

Code "G90 Z#1200"

Code "G0 Z#1200X[#1301 + .2250] Y#1302"

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

While IsMoving()

Wend

End Sub

Sub ONE

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

message "One"

Code "G90 g0 X[#1301 + .2250] Y#1302 "

code "G91G0X-.0359Y.0719"

code "G90 G1Z#1300 F20."

code "G91 X.0357Y.0361"

code "Y-.2156"

code "X-.0357"

code "X.0718"

code "G90 G0 Z#1200"

Code "G0 Z#1200X[#1301 + .2250] Y#1302"

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

While IsMoving()

Wend

End Sub

Sub TWO

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

message "Two"

Code "G90 G0 Z#1200 X[#1301 + .2250] Y#1302 "

code "G91G0X-.071Y.0531 "

code "G90 G1Z#1300 F20. "

code "G91 G2X.0157Y.0375I.0535J-.0004 "

code "X.0377Y.0159I.0379J-.0371"

code "G1X.0352 "

code "G2X.0375Y-.0159I-.0005J-.0531 "

code "X.0159Y-.0375I-.0373J-.038 "

code "X-.0164Y-.0383I-.0527J-.0001"

code "G1X-.1256Y-.1213"

code "X.142"

code "G90 G0Z#1200"

Code "G0 Z#1200 X[#1301 + .2250] Y#1302 "

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

While IsMoving()

Wend

End Sub

Sub THREE

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

message "Three"

code "g90 G0 Z#1200 X[#1301 + .2250] Y[#1302 ]"

code "G91G0X-.0605Y.0917"

code "G90 G1Z#1300 F20."

code "G91 G2X.0362Y.0159I.0366J-.0341"

code "G1X.034"

code "G2X.0357Y-.0159I-.0006J-.0494"

code "X.0151Y-.0379I-.04J-.0379"

code "X-.0151Y-.0379I-.0552 "

code "X-.0357Y-.0159I-.0363J.0335"

code "X.0357Y-.0159I-.0006J-.0494"

code "X.0151Y-.0379I-.04J-.0379"

code "X-.0151Y-.0374I-.0546J.0002 "

code "X-.0357Y-.0159I-.0363J.0335"

code "G1X-.034 "

code "G2X-.0362Y.0154I.0002J.0505 "

code "G90 G0Z[#1200]"

Code "G0 Z#1200X[#1301 + .2250] Y#1302"

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

While IsMoving()

Wend

End Sub

Sub FOUR

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

message "Four"

Code "g90 G0 Z#1200 X[#1301 + .2250] Y#1302 "

code "G91G0X.0353Y-.1059"

code "G90 G1Z#1300 F20."

code "G91 Y.2117"

code "X-.1059Y-.1411"

code "X.1412"

code "G90 G0Z#1200"

Code "G0 Z#1200 X[#1301 + .2250] Y#1302 "

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

While IsMoving()

Wend

End Sub

Sub FIVE

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

message "Five"

Code "G90 G0 Z#1200 X[#1301 + .2250] Y#1302 "

code "G91G0X.0714Y.1071"

code "G90 G1Z#1300 F20."

code "G91 X-.1428"

code " Y-.0714"

code "X.0895"

code "G2X.0374Y-.0159I-.0005J-.0531"

code "X.0159Y-.0374I-.0372J-.0379"

code "G1Y-.0358"

code "G2X-.0159Y-.0378I-.0537J.0003"

code "X-.0374Y-.0159I-.0379J.0372"

code "G1X-.0357"

code "G2X-.0379Y.0159I.0002J.0536"

code "X-.0159Y.0374I.0372J.0379"

code "G90 G0Z#1200"

Code "G0 Z#1200 X[#1301 + .2250] Y#1302 "

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

While IsMoving()

Wend

End Sub

Sub SIX

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

message "Six"

Code "G90 G0 Z#1200 X[#1301 + .2250] Y#1302 "

code "G91G0X.0555Y.091"

code "G90 G1Z#1300 F20."

code "G91 G3X-.0379Y.0155I-.0376J-.038"

code "G1X-.0352"

code "G3X-.0377Y-.0159I.0002J-.053"

code "X-.0157Y-.0375I.0378J-.0379"

code "G1Y-.1062"

code "G3X.0157Y-.0377I.0533J.0001"

code "X.0377Y-.0157I.0378J.0376"

code "G1X.0352"

code "X.0375Y.0157I-.0004J.0535"

code "X.0159Y.0377I-.0371J.0379"

code "G1Y.0352"

code "G3X-.0159Y.0375I-.0531J-.0005"

code "X-.0375Y.0159I-.038J-.0372"

code "G1X-.0352"

code "G3X-.0377Y-.0159I.0002J-.053"

code "X-.0157Y-.0375I.0378J-.0379"

code "G90 G0Z[#1200]"

Code "G0 Z#1200 X[#1301 + .2250] Y#1302 "

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

While IsMoving()

Wend

End Sub

Sub SEVEN

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

message "Seven"

Code "G0 Z#1200 X[#1301 + .2250] Y#1302 "

code "G90 z#1200"

code "G91G0X-.0714Y.1071"

code "G90 G1Z#1300 F20."

code "G91 X.1428"

code "X-.1071Y-.2142"

code "G90 G0Z[#1200]"

Code "G0 Z#1200 X[#1301 + .2250] Y#1302 "

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

While IsMoving()

Wend

End Sub

Sub EIGHT

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

message "Eight"

Code "g90 G0 Z#1200 X[#1301 + .2250] Y#1302 "

code "G91G0X0.Y.1061"

code "G90 G1Z#1300 F20."

code "G91 X.0176"

code "G2X.0373Y-.016I-.0004J-.0525"

code "X.0157Y-.0374I-.0378J-.0378"

code "X-.0157Y-.0372I-.0528J.0004"

code "X-.0373Y-.0157I-.0376J.0371"

code "G1X-.0352"

code "G3X-.0373Y-.0164I.0005J-.0519"

code "X-.0157Y-.0383I.0398J-.0386"

code "X.0159Y-.0361I.05J.0004"

code "X.0375Y-.0151I.0377J.0395"

code "G1X.0348"

code "G3X.0373Y.0151I-.0001J.0539"

code "X.0157Y.0361I-.0346J.0365"

code "X-.016Y.0383I-.0551J-.0004"

code "X-.037Y.0164I-.0378J-.0356"

code "G1X-.0352"

code "G2X-.0373Y.0157I.0003J.0528"

code "X-.0157Y.0372I.0371J.0376"

code "X.0157Y.0374I.0535J-.0004"

code "X.0373Y.016I.0377J-.0365"

code "G1X.0176"

code "G90 G0Z[#1200]"

Code "G0 Z#1200 X[#1301 + .2250] Y#1302 "

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

While IsMoving()

Wend

End Sub

Sub NINE

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

message "Nine"

Code "G90 G0 Z#1200 X[#1301 +.2250] Y#1302 "

code "G91G0X-.0555Y-.091"

code "G90 G1Z#1300 F20."

code "G91 G3X.0379Y-.0155I.0376J.038"

code "G1X.0352"

code "G3X.0375Y.0157I-.0004J.0535"

code "X.0159Y.0377I-.0371J.0379"

code "G1Y.1062"

code "G3X-.0159Y.0375I-.0532J-.0005"

code "X-.0375Y.0159I-.038J-.0372"

code "G1X-.0352"

code "G3X-.0377Y-.0159I.0002J-.053"

code "X-.0157Y-.0375I.0378J-.0379"

code "G1Y-.0352"

code "G3X.0157Y-.0377I.0533J.0001"

code "X.0377Y-.0157I.0378J.0376"

code "G1X.0352"

code "G3X.0375Y.0157I-.0004J.0535"

code "X.0159Y.0377I-.0371J.0379"

code "G90 G0Z#1200"

Code "G0 Z#1200 X[#1301 +.2250] Y#1302 "

Setvar(1301, getdro(0))

Setvar(1302, getdro(1))

While IsMoving()

Wend

End Sub

SETIJMODE(0)

CODE"G90"

CODE"M30"