; poly_frame - perimeter cut of a regular polygon. ; apothem = flat-to-flat distance / 2 (center to midpoint of edge). ; rotation in degrees: 0 places first vertex on +X axis, CCW positive. ; Requires globals: #<_z_top>, #<_z_bot> ; Requires tool loaded (uses #5410 for diameter) ; Optional global: #<_z_clearance> o sub ; o call [mode] [x][y] [n_sides] [apothem] [rotation] [fincut] ; #1=mode #2=x #3=y #4=n_sides #5=apothem #6=rotation #7=fincut # = [FIX[#1/1] MOD 2 EQ 1] # = [FIX[#1/8] MOD 2 EQ 1] # = [FIX[#1/1] MOD 2 EQ 0] # = [FIX[#1/8] MOD 2 EQ 0] G90 G90.1 M101 G17 # = #5410 # = [#/2] o1 if [EXISTS[#<_z_clearance>]] # = #<_z_clearance> o1 else # = #<_z_top> o1 endif o10 if [#] # = [#5 - # - #7] o10 else # = [#5 + # + #7] o10 endif # = [# / COS[180/#4]] # = [360/#4] o11 if [[# AND #] OR [# AND #]] # = 1 o11 else # = -1 o11 endif G0 Z# # = [#2 + #*COS[#6]] # = [#3 + #*SIN[#6]] G0 X# Y# G0 Z#<_z_top> G1 Z#<_z_bot> # = 1 o20 while [# LE #4] # = [#6 + #*#*#] G1 X[#2 + #*COS[#]] Y[#3 + #*SIN[#]] # = [# + 1] o20 endwhile G0 Z# o endsub M2