Shopbot postprocessor by Denver Hull

huge thanks!
pull/4/head
vilda.novak@gmail.com 2015-01-10 19:41:59 +00:00
rodzic 2aa479fb12
commit 418fefee25
3 zmienionych plików z 226 dodań i 2 usunięć

Wyświetl plik

@ -65,7 +65,7 @@ class machineSettings(bpy.types.PropertyGroup):
'''stores all data for machines'''
#name = bpy.props.StringProperty(name="Machine Name", default="Machine")
post_processor = EnumProperty(name='Post processor',
items=(('ISO','Iso','this should export a standardized gcode'),('MACH3','Mach3','default mach3'),('EMC','EMC - LinuxCNC','default emc'),('HEIDENHAIN','Heidenhain','heidenhain'),('TNC151','Heidenhain TNC151','Post Processor for the Heidenhain TNC151 machine'),('SIEGKX1','Sieg KX1','Sieg KX1'),('HM50','Hafco HM-50','Hafco HM-50'),('CENTROID','Centroid M40','Centroid M40'),('ANILAM','Anilam Crusader M','Anilam Crusader M'),('GRAVOS','Gravos','Gravos'),('WIN-PC','Win-PC','German CNC')),
items=(('ISO','Iso','this should export a standardized gcode'),('MACH3','Mach3','default mach3'),('EMC','EMC - LinuxCNC','default emc'),('HEIDENHAIN','Heidenhain','heidenhain'),('TNC151','Heidenhain TNC151','Post Processor for the Heidenhain TNC151 machine'),('SIEGKX1','Sieg KX1','Sieg KX1'),('HM50','Hafco HM-50','Hafco HM-50'),('CENTROID','Centroid M40','Centroid M40'),('ANILAM','Anilam Crusader M','Anilam Crusader M'),('GRAVOS','Gravos','Gravos'),('WIN-PC','Win-PC','German CNC'),('SHOPBOT PRS','ShopBot PRS','ShopBot PRS')),
description='Post processor',
default='MACH3')
#units = EnumProperty(name='Units', items = (('IMPERIAL', ''))

Wyświetl plik

@ -0,0 +1,222 @@
################################################################################
# shopbot_prs.py
#
# Simple ShopBot NC code creator
#
# dhull, January 2015
# from iso.py
#
# TTD:
# 1. need to get unit scale from system
# 2. need to get start, end, toolchange positions from system
# 3. need to get tool description from system
# 4. get arcs working
# 5. remove unused stuff
#
from . import nc
import math
from .format import Format
from .format import *
################################################################################
class Creator(nc.Creator):
def __init__(self):
nc.Creator.__init__(self)
self.fmt = Format()
self.ffmt = Format(number_of_decimal_places = 2)
self.sfmt = Format(number_of_decimal_places = 1)
self.unitscale = 0.0254
self.startx = 14
self.starty = 25
self.startz = 4
self.endx = 14
self.endy = 25
self.endz = 4
self.tcx = 14
self.tcy = 25
self.tcz = 4
self.metric_flag = False
self.absolute_flag = True
############################################################################
## Codes
def SPACE(self): return('')
def COMMENT(self,comment): return( '\' %s' % comment )
def TOOL(self): return('T%i' + self.SPACE() + 'M06')
############################################################################
## Internals
def write_feedrate(self):
self.f.write(self)
def write_spindle(self):
self.s.write(self)
############################################################################
## Programs
def program_begin(self, id, name=''):
self.writem([self.SPACE() , self.COMMENT(name)])
self.write('\n\n')
self.write('IF %(25)=1 THEN GOTO UNIT_ERROR\n')
self.write('\n')
def program_end(self):
self.write('J2,' + self.fmt.string(self.endx) + ',' + self.fmt.string(self.endy) + '\n')
self.write('C7\n')
self.write('END\n')
self.write('\'\n')
self.write('UNIT_ERROR:\n')
self.write('C#,91\n')
self.write('END\n')
def flush_nc(self):
return
############################################################################
## Subprograms
############################################################################
## Settings
def imperial(self):
self.fmt.number_of_decimal_places = 4
self.unitscale = 0.0254
self.metric_flag=False
def metric(self):
self.metric_flag=True
self.unitscale = 1
self.fmt.number_of_decimal_places = 3
def absolute(self):
self.absolute_flag = True
self.write('SA\n')
def incremental(self):
self.absolute_flag = False
self.write('SR\n')
def set_plane(self, plane):
return
############################################################################
## new graphics origin- make a new coordinate system and snap it onto the geometry
## the toolpath generated should be translated
############################################################################
## Tools
def tool_change(self, id):
self.write('&Tool='+(self.TOOL() % id)+'\n')
self.write('JZ,' + (self.fmt.string(self.tcz)) + '\n')
self.write('J2,' + (self.fmt.string(self.tcx)) + ',' + (self.fmt.string(self.tcy)) + '\n')
self.write('\' Tool: '+(self.TOOL() % id)+'\n')
self.write('PAUSE\n')
self.write('C2\n')
self.t = id
############################################################################
## Datums
############################################################################
## Rates + Modes
def feedrate(self, f):
if (self.metric_flag == True):
self.write('MS,' + (self.sfmt.string(f)) + ',' + (self.sfmt.string(f)) + '\n')
else:
# adjust for IPS, and Z = 1/2 XY
self.write('MS,' + (self.sfmt.string(f/60*.0254)) + ',' + (self.sfmt.string(f/120*.0254)) + '\n')
def spindle(self, s, clockwise):
self.write('TR,' + self.fmt.string(s) + '\n')
############################################################################
## Moves
def rapid(self, x=None, y=None, z=None, a=None, b=None, c=None, machine_coordinates=None ):
# different commands for X only, or Y only, or Z only, or (X and Y), or (X, Y, and Z)
if (x != None and y != None and z != None):
self.write('J3,' + (self.fmt.string(x * self.unitscale)))
self.write(',' + (self.fmt.string(y * self.unitscale)))
self.write(',' + (self.fmt.string(z * self.unitscale)))
self.write('\n')
elif (x != None and y != None and z == None):
self.write('J2,' + (self.fmt.string(x * self.unitscale)))
self.write(',' + (self.fmt.string(y * self.unitscale)))
self.write('\n')
elif (x != None):
self.write('JX,' + (self.fmt.string(x * self.unitscale)) + '\n')
elif (y != None):
self.write('JY,' + (self.fmt.string(y * self.unitscale)) + '\n')
elif (z != None):
self.write('JZ,' + (self.fmt.string(z * self.unitscale)) + '\n')
def feed(self, x=None, y=None, z=None, a=None, b=None, c=None):
if (x != None and y != None and z != None):
self.write('M3,' + (self.fmt.string(x * self.unitscale)))
self.write(',' + (self.fmt.string(y * self.unitscale)))
self.write(',' + (self.fmt.string(z * self.unitscale)))
self.write('\n')
elif (x != None and y != None and z == None):
self.write('M2,' + (self.fmt.string(x * self.unitscale)))
self.write(',' + (self.fmt.string(y * self.unitscale)))
self.write('\n')
elif (x != None):
self.write('MX,' + (self.fmt.string(x * self.unitscale)) + '\n')
elif (y != None):
self.write('MY,' + (self.fmt.string(y * self.unitscale)) + '\n')
elif (z != None):
self.write('MZ,' + (self.fmt.string(z * self.unitscale)) + '\n')
def arc(self, cw, x=None, y=None, z=None, i=None, j=None, k=None, r=None):
if (r != None):
self.write('CG,' + self.fmt.string(r * self.unitscale * 2))
self.write(',' + self.fmt.string(x * self.unitscale))
self.write(',' + self.fmt.string(y * self.unitscale))
self.write(', ,')
self.write(',T,1')
self.write('\n')
else:
self.write('CG, ')
self.write(',' + self.fmt.string(x * self.unitscale))
self.write(',' + self.fmt.string(y * self.unitscale))
self.write(',' + self.fmt.string(i * self.unitscale))
self.write(',' + self.fmt.string(j * self.unitscale))
self.write(',T,1')
self.write('\n')
return
############################################################################
## CRC
############################################################################
## Cycles
############################################################################
## Misc
def comment(self, text):
self.write((self.COMMENT(text) + '\n'))
def variable(self, id):
return (self.VARIABLE() % id)
def variable_set(self, id, value):
self.write('&' + (self.VARIABLE() % id) + self.SPACE() + (self.VARIABLE_SET() % value) + '\n')
################################################################################
nc.creator = Creator()

Wyświetl plik

@ -1072,7 +1072,9 @@ def exportGcodePath(filename,vertslist,operations):
elif m.post_processor=='WIN-PC' :
extension='.din'
from .nc import winpc as postprocessor
elif m.post_processor=='SHOPBOT PRS':
extension='.sbp'
from .nc import shopbot_prs as postprocessor
if s.unit_settings.system=='METRIC':
unitcorr=1000.0