Ball In Cage

G21 G90 G91.1
#<size> = 30 (size of box)
#<tool> = 1.5 (tool radius)
#<edge> = 2 (size of box edge)
#<res> = 5 (resolution)
#<cnt> = #<res> (counter)
#<rad> = [[#<size>/2]+#<tool>] (radius of circle = tool radius + bos size) 
G00 X0 Y0 Z5
o140 do 
   #<xy> = [[SIN[#<cnt>]*#<rad>]*SIN[45]] ( X and Y position)
   #<z> = [0-[[1-COS[#<cnt>]]*#<rad>]] (Z height)
   G01 X[#<xy>] Y[#<xy>] 
   G01 Z[#<z>]
   G18 G02 X[0-#<xy>] Z[#<z>] I[0-#<xy>] K[0-[#<z>+[#<rad>]]]
   G19 G03 Y[0-#<xy>] Z[#<z>] J[0-#<xy>] K[0-[#<z>+[#<rad>]]]
   G18 G03 X[#<xy>] Z[#<z>] I[#<xy>] K[0-[#<z>+[#<rad>]]]
   G19 G02 Y[#<xy>] Z[#<z>] J[#<xy>] K[0-[#<z>+[#<rad>]]]
   #<cnt> = [#<cnt>+#<res>]
o140 while [#<xy> LT [#<size>/2-#<tool>-#<edge>]]
G00 Z5
G00 X0 Y0
M2