Skip to content

Instantly share code, notes, and snippets.

@itguy51
Last active December 21, 2015 08:28
Show Gist options
  • Save itguy51/6278172 to your computer and use it in GitHub Desktop.
Save itguy51/6278172 to your computer and use it in GitHub Desktop.
GCode Python Library, Rough Phase 1.
def circleCW(radius, cx, cy, cz, sinkDepth, bitRadius=0):
radius = radius-bitRadius
print "G00 X" + str(cx-radius) + " Y"+str(cy)
print "G01 Z" + str(cz-sinkDepth)
print "G02 X" + str(cx-radius) + " Y"+str(cy) + " R" + str(radius)
print "G02 X" + str(radius+cx) + " R" + str(radius)
print "G02 X" + str(cx-radius) + " R" + str(radius)
print "G01 Z" + str(cz)
def toolToPosition(tx, ty):
#This uses G00 positioning, Not suitable for cutting.
print "G00 X" + str(tx) + " Y" + str(ty)
def linearInterpolate(tx, ty, tz):
print "G01 X" + str(tx) + " Y" + str(ty) + " Z" + str(tz)
def coolantFlood():
print "M07"
def coolantMist():
print "M08"
def coolantOff():
print "M09"
def spindleCW():
print "M03"
def spindleCCW():
print "M04"
def compStop():
print "M00"
def optStop():
print "M01"
def spindleStop():
print "M05"
def endProg():
print "M02"
def setInches():
print "; GCode.py generated"
print "G20"
def setMil():
print "; GCode.py generated"
print "G21"
def frcBearingHole(x, y, d):
circleCW((1.125/2), x, y, 0, d, 0.125)
setInches()
toolToPosition(5, 5)
toolToPosition(0, 0)
linearInterpolate(0, 0, -0.5)
linearInterpolate(0, 5, -0.5)
linearInterpolate(0, 5, 0)
circleCW((1.125/2), 0, 5, 0, 0.5, 0.125)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment