NC library update

Update NC library to Heekscnc NC version 1.0
- feed now accepts 6 axis parameters
- tool_defn function now uses a params list instead of individual param
names
- improved drill cycle
- improved number formating - better rounding
- block numbering now automatic - no longer need to call
write_blocknum().
- dwell works now
pull/25/head
Jeff Doyle (nfz) 2016-01-27 19:34:01 -04:00
rodzic 8e3feea939
commit d53929d685
28 zmienionych plików z 1511 dodań i 2047 usunięć

Wyświetl plik

@ -78,7 +78,7 @@ class Creator(iso.Creator):
self.write(('T%i' % id) + '\n')
self.t = id
def tool_defn(self, id, name='', radius=None, length=None, gradient=None):
def tool_defn(self, id, name='', params=None):
self.write_blocknum()
self.write(('T10%.2d' % id) + ' ')
@ -104,8 +104,7 @@ class Creator(iso.Creator):
def write_blocknum(self):
pass
def drill(self, x=None, y=None, z=None, depth=None, standoff=None, dwell=None, peck_depth=None,retract_mode=None, spindle_mode=None):
def drill(self, x=None, y=None, dwell=None, depthparams = None, retract_mode=None, spindle_mode=None, internal_coolant_on=None, rapid_to_clearance = None):
self.write('(Canned drill cycle ops are not yet supported here on this Anilam Crusader M postprocessor)')
nc.creator = Creator()

Wyświetl plik

@ -10,6 +10,7 @@ import ocl_funcs
import nc
attached = False
units = 1.0
################################################################################
class Creator(recreator.Redirector):
@ -33,7 +34,7 @@ class Creator(recreator.Redirector):
self.pdcf.setSTL(self.stl)
self.pdcf.setCutter(self.cutter)
self.pdcf.setSampling(0.1)
self.pdcf.setZ(self.minz)
self.pdcf.setZ(self.minz/units)
def z2(self, z):
path = ocl.Path()
@ -43,12 +44,12 @@ class Creator(recreator.Redirector):
if (self.z>self.minz):
self.pdcf.setZ(self.z) # Adjust Z if we have gotten a higher limit (Fix pocketing loosing steps when using attach?)
else:
self.pdcf.setZ(self.minz) # Else use minz
self.pdcf.setZ(self.minz/units) # Else use minz
self.pdcf.setPath(path)
self.pdcf.run()
plist = self.pdcf.getCLPoints()
p = plist[0]
return p.z + self.material_allowance
return p.z + self.material_allowance/units
def cut_path(self):
if self.path == None: return
@ -57,10 +58,11 @@ class Creator(recreator.Redirector):
if (self.z>self.minz):
self.pdcf.setZ(self.z) # Adjust Z if we have gotten a higher limit (Fix pocketing loosing steps when using attach?)
else:
self.pdcf.setZ(self.minz) # Else use minz
self.pdcf.setZ(self.minz/units) # Else use minz
# get the points on the surface
self.pdcf.setPath(self.path)
self.pdcf.run()
plist = self.pdcf.getCLPoints()
@ -75,16 +77,22 @@ class Creator(recreator.Redirector):
i = 0
for p in plist:
if i > 0:
self.original.feed(p.x/units, p.y/units, p.z/units + self.material_allowance)
self.original.feed(p.x/units, p.y/units, p.z/units + self.material_allowance/units)
i = i + 1
self.path = ocl.Path()
def rapid(self, x=None, y=None, z=None, a=None, b=None, c=None ):
if z != None:
if z < self.z:
return
recreator.Redirector.rapid(self, x, y, z, a, b, c)
def feed(self, x=None, y=None, z=None):
def feed(self, x=None, y=None, z=None, a=None, b=None, c=None):
px = self.x
py = self.y
pz = self.z
recreator.Redirector.feed(self, x, y, z)
recreator.Redirector.feed(self, x, y, z, a, b, c)
if self.x == None or self.y == None or self.z == None:
return
if px == self.x and py == self.y:
@ -103,6 +111,9 @@ class Creator(recreator.Redirector):
# add an arc to the path
if self.path == None: self.path = ocl.Path()
self.path.append(ocl.Arc(ocl.Point(px, py, pz), ocl.Point(self.x, self.y, self.z), ocl.Point(i, j, pz), ccw))
def set_ocl_cutter(self, cutter):
self.cutter = cutter
################################################################################
@ -111,6 +122,7 @@ def attach_begin():
if attached == True:
attach_end()
nc.creator = Creator(nc.creator)
recreator.units = units
attached = True
nc.creator.pdcf = None
nc.creator.path = None

Wyświetl plik

@ -130,7 +130,7 @@ class Creator(iso_modal.Creator):
self.write ('\n')
def tool_defn(self, id, name='', radius=None, length=None, gradient=None):
def tool_defn(self, id, name='', params=None):
#self.write('G43 \n')
pass

Wyświetl plik

@ -37,11 +37,11 @@ class Creator(recreator.Redirector):
self.path = area.Curve()
def feed(self, x=None, y=None, z=None):
def feed(self, x=None, y=None, z=None, a=None, b=None, c=None):
px = self.x
py = self.y
pz = self.z
recreator.Redirector.feed(self, x, y, z)
recreator.Redirector.feed(self, x, y, z, a, b, c)
if self.x == None or self.y == None or self.z == None:
return
if px == self.x and py == self.y:

Wyświetl plik

@ -21,275 +21,199 @@ class Creator(iso.Creator):
## Settings
def imperial(self):
self.write_blocknum()
self.write( self.IMPERIAL() + '\t (Imperial Values)\n')
self.fmt.number_of_decimal_places = 4
def metric(self):
self.write_blocknum()
self.fmt.number_of_decimal_places = 3
self.write( self.METRIC() + '\t (Metric Values)\n' )
def absolute(self):
self.write_blocknum()
self.write( self.ABSOLUTE() + '\t (Absolute Coordinates)\n')
def incremental(self):
self.write_blocknum()
self.write( self.INCREMENTAL() + '\t (Incremental Coordinates)\n' )
def polar(self, on=True):
if (on) :
self.write_blocknum()
self.write(self.POLAR_ON() + '\t (Polar ON)\n' )
else :
self.write_blocknum()
self.write(self.POLAR_OFF() + '\t (Polar OFF)\n' )
def set_plane(self, plane):
if (plane == 0) :
self.write_blocknum()
self.write(self.PLANE_XY() + '\t (Select XY Plane)\n')
elif (plane == 1) :
self.write_blocknum()
self.write(self.PLANE_XZ() + '\t (Select XZ Plane)\n')
elif (plane == 2) :
self.write_blocknum()
self.write(self.PLANE_YZ() + '\t (Select YZ Plane)\n')
def comment(self, text):
self.write_blocknum()
self.write((self.COMMENT(text) + '\n'))
# This is the coordinate system we're using. G54->G59, G59.1, G59.2, G59.3
# These are selected by values from 1 to 9 inclusive.
def workplane(self, id):
if ((id >= 1) and (id <= 6)):
self.write_blocknum()
self.write( (self.WORKPLANE() % (id + self.WORKPLANE_BASE())) + '\t (Select Relative Coordinate System)\n')
if ((id >= 7) and (id <= 9)):
self.write_blocknum()
self.write( ((self.WORKPLANE() % (6 + self.WORKPLANE_BASE())) + ('.%i' % (id - 6))) + '\t (Select Relative Coordinate System)\n')
def report_probe_results(self, x1=None, y1=None, z1=None, x2=None, y2=None, z2=None, x3=None, y3=None, z3=None, x4=None, y4=None, z4=None, x5=None, y5=None, z5=None, x6=None, y6=None, z6=None, xml_file_name=None ):
if (xml_file_name != None):
self.comment('Generate an XML document describing the probed coordinates found');
self.write_blocknum()
self.write('(LOGOPEN,')
self.write(xml_file_name)
self.write(')\n')
self.write_blocknum()
self.write('(LOG,<POINTS>)\n')
if ((x1 != None) or (y1 != None) or (z1 != None)):
self.write_blocknum()
self.write('(LOG,<POINT>)\n')
if (x1 != None):
self.write_blocknum()
self.write('#<_value>=[' + x1 + ']\n')
self.write_blocknum()
self.write('(LOG,<X>#<_value></X>)\n')
if (y1 != None):
self.write_blocknum()
self.write('#<_value>=[' + y1 + ']\n')
self.write_blocknum()
self.write('(LOG,<Y>#<_value></Y>)\n')
if (z1 != None):
self.write_blocknum()
self.write('#<_value>=[' + z1 + ']\n')
self.write_blocknum()
self.write('(LOG,<Z>#<_value></Z>)\n')
if ((x1 != None) or (y1 != None) or (z1 != None)):
self.write_blocknum()
self.write('(LOG,</POINT>)\n')
if ((x2 != None) or (y2 != None) or (z2 != None)):
self.write_blocknum()
self.write('(LOG,<POINT>)\n')
if (x2 != None):
self.write_blocknum()
self.write('#<_value>=[' + x2 + ']\n')
self.write_blocknum()
self.write('(LOG,<X>#<_value></X>)\n')
if (y2 != None):
self.write_blocknum()
self.write('#<_value>=[' + y2 + ']\n')
self.write_blocknum()
self.write('(LOG,<Y>#<_value></Y>)\n')
if (z2 != None):
self.write_blocknum()
self.write('#<_value>=[' + z2 + ']\n')
self.write_blocknum()
self.write('(LOG,<Z>#<_value></Z>)\n')
if ((x2 != None) or (y2 != None) or (z2 != None)):
self.write_blocknum()
self.write('(LOG,</POINT>)\n')
if ((x3 != None) or (y3 != None) or (z3 != None)):
self.write_blocknum()
self.write('(LOG,<POINT>)\n')
if (x3 != None):
self.write_blocknum()
self.write('#<_value>=[' + x3 + ']\n')
self.write_blocknum()
self.write('(LOG,<X>#<_value></X>)\n')
if (y3 != None):
self.write_blocknum()
self.write('#<_value>=[' + y3 + ']\n')
self.write_blocknum()
self.write('(LOG,<Y>#<_value></Y>)\n')
if (z3 != None):
self.write_blocknum()
self.write('#<_value>=[' + z3 + ']\n')
self.write_blocknum()
self.write('(LOG,<Z>#<_value></Z>)\n')
if ((x3 != None) or (y3 != None) or (z3 != None)):
self.write_blocknum()
self.write('(LOG,</POINT>)\n')
if ((x4 != None) or (y4 != None) or (z4 != None)):
self.write_blocknum()
self.write('(LOG,<POINT>)\n')
if (x4 != None):
self.write_blocknum()
self.write('#<_value>=[' + x4 + ']\n')
self.write_blocknum()
self.write('(LOG,<X>#<_value></X>)\n')
if (y4 != None):
self.write_blocknum()
self.write('#<_value>=[' + y4 + ']\n')
self.write_blocknum()
self.write('(LOG,<Y>#<_value></Y>)\n')
if (z4 != None):
self.write_blocknum()
self.write('#<_value>=[' + z4 + ']\n')
self.write_blocknum()
self.write('(LOG,<Z>#<_value></Z>)\n')
if ((x4 != None) or (y4 != None) or (z4 != None)):
self.write_blocknum()
self.write('(LOG,</POINT>)\n')
if ((x5 != None) or (y5 != None) or (z5 != None)):
self.write_blocknum()
self.write('(LOG,<POINT>)\n')
if (x5 != None):
self.write_blocknum()
self.write('#<_value>=[' + x5 + ']\n')
self.write_blocknum()
self.write('(LOG,<X>#<_value></X>)\n')
if (y5 != None):
self.write_blocknum()
self.write('#<_value>=[' + y5 + ']\n')
self.write_blocknum()
self.write('(LOG,<Y>#<_value></Y>)\n')
if (z5 != None):
self.write_blocknum()
self.write('#<_value>=[' + z5 + ']\n')
self.write_blocknum()
self.write('(LOG,<Z>#<_value></Z>)\n')
if ((x5 != None) or (y5 != None) or (z5 != None)):
self.write_blocknum()
self.write('(LOG,</POINT>)\n')
if ((x6 != None) or (y6 != None) or (z6 != None)):
self.write_blocknum()
self.write('(LOG,<POINT>)\n')
if (x6 != None):
self.write_blocknum()
self.write('#<_value>=[' + x6 + ']\n')
self.write_blocknum()
self.write('(LOG,<X>#<_value></X>)\n')
if (y6 != None):
self.write_blocknum()
self.write('#<_value>=[' + y6 + ']\n')
self.write_blocknum()
self.write('(LOG,<Y>#<_value></Y>)\n')
if (z6 != None):
self.write_blocknum()
self.write('#<_value>=[' + z6 + ']\n')
self.write_blocknum()
self.write('(LOG,<Z>#<_value></Z>)\n')
if ((x6 != None) or (y6 != None) or (z6 != None)):
self.write_blocknum()
self.write('(LOG,</POINT>)\n')
self.write_blocknum()
self.write('(LOG,</POINTS>)\n')
if (xml_file_name != None):
self.write_blocknum()
self.write('(LOGCLOSE)\n')
def open_log_file(self, xml_file_name=None ):
self.write_blocknum()
self.write('(LOGOPEN,')
self.write(xml_file_name)
self.write(')\n')
def close_log_file(self):
self.write_blocknum()
self.write('(LOGCLOSE)\n')
def log_coordinate(self, x=None, y=None, z=None):
if ((x != None) or (y != None) or (z != None)):
self.write_blocknum()
self.write('(LOG,<POINT>)\n')
if (x != None):
self.write_blocknum()
self.write('#<_value>=[' + x + ']\n')
self.write_blocknum()
self.write('(LOG,<X>#<_value></X>)\n')
if (y != None):
self.write_blocknum()
self.write('#<_value>=[' + y + ']\n')
self.write_blocknum()
self.write('(LOG,<Y>#<_value></Y>)\n')
if (z != None):
self.write_blocknum()
self.write('#<_value>=[' + z + ']\n')
self.write_blocknum()
self.write('(LOG,<Z>#<_value></Z>)\n')
if ((x != None) or (y != None) or (z != None)):
self.write_blocknum()
self.write('(LOG,</POINT>)\n')
def log_message(self, message=None ):
self.write_blocknum()
self.write('(LOG,' + message + ')\n')
def start_CRC(self, left = True, radius = 0.0):
if self.t == None:
raise "No tool specified for start_CRC()"
self.write_blocknum()
if left:
self.write(('G41' + self.SPACE() + 'D%i') % self.t + '\t (start left cutter radius compensation)\n' )
else:
@ -297,143 +221,14 @@ class Creator(iso.Creator):
def end_CRC(self):
self.g = 'G40'
self.write_blocknum()
self.write_preps()
self.write_misc()
self.write('\t (end cutter radius compensation)\n')
# The drill routine supports drilling (G81), drilling with dwell (G82) and peck drilling (G83).
# The x,y,z values are INITIAL locations (above the hole to be made. This is in contrast to
# the Z value used in the G8[1-3] cycles where the Z value is that of the BOTTOM of the hole.
# Instead, this routine combines the Z value and the depth value to determine the bottom of
# the hole.
#
# The standoff value is the distance up from the 'z' value (normally just above the surface) where the bit retracts
# to in order to clear the swarf. This combines with 'z' to form the 'R' value in the G8[1-3] cycles.
#
# The peck_depth value is the incremental depth (Q value) that tells the peck drilling
# cycle how deep to go on each peck until the full depth is achieved.
#
# NOTE: This routine forces the mode to absolute mode so that the values passed into
# the G8[1-3] cycles make sense. I don't know how to find the mode to revert it so I won't
# revert it. I must set the mode so that I can be sure the values I'm passing in make
# sense to the end-machine.
#
# extended argument list for EMC boring mah 30102001
# retract_mode : 0 - rapid retract, 1 - feed retract
# spindle_mode ; if true, stop spindle at bottom, otherwise keep runnung
def drill(self, x=None, y=None, z=None, depth=None, standoff=None, dwell=None, peck_depth=None, retract_mode=None, spindle_mode=None):
if standoff == None:
# This is a bad thing. All the drilling cycles need a retraction (and starting) height.
return
if (z == None):
return # We need a Z value as well. This input parameter represents the top of the hole
self.write_preps()
self.write_blocknum()
if (peck_depth != 0):
if spindle_mode == 1:
raise "cannot stop spindle at bottom while peck drilling"
if retract_mode == 1:
raise "cannot feed retract while peck drilling"
# We're pecking. Let's find a tree.
if self.drill_modal:
if self.PECK_DRILL() + self.PECK_DEPTH(self.fmt, peck_depth) != self.prev_drill:
self.write(self.PECK_DRILL() + self.PECK_DEPTH(self.fmt, peck_depth))
self.prev_drill = self.PECK_DRILL() + self.PECK_DEPTH(self.fmt, peck_depth)
else:
self.write(self.PECK_DRILL() + self.PECK_DEPTH(self.fmt, peck_depth))
else:
if (spindle_mode == 1) or (retract_mode == 1):
# this is a boring cycle.
if (spindle_mode == 0): # keep spindle running, feed retract
if (dwell == 0):
self.write(self.BORE_FEED_OUT())
else:
self.write(self.BORE_DWELL_FEED_OUT(self.FORMAT_DWELL(), dwell))
else:
# stop spindle at bottom
self.write(self.BORE_SPINDLE_STOP_RAPID_OUT())
if (dwell > 0):
self.write( self.SPACE() + self.FORMAT_DWELL() % dwell)
# We're either just drilling or drilling with dwell.
else:
if (dwell == 0):
# We're just drilling.
if self.drill_modal:
if self.DRILL() != self.prev_drill:
self.write(self.DRILL())
self.prev_drill = self.DRILL()
else:
self.write(self.DRILL())
else:
# We're drilling with dwell.
if self.drill_modal:
if self.DRILL_WITH_DWELL(self.FORMAT_DWELL(), dwell) != self.prev_drill:
self.write(self.DRILL_WITH_DWELL(self.FORMAT_DWELL(), dwell))
self.prev_drill = self.DRILL_WITH_DWELL(self.FORMAT_DWELL(), dwell)
else:
self.write(self.DRILL_WITH_DWELL(self.FORMAT_DWELL(), dwell))
#self.write(self.DRILL_WITH_DWELL(self.FORMAT_DWELL(),dwell))
# Set the retraction point to the 'standoff' distance above the starting z height.
retract_height = z + standoff
if (x != None):
dx = x - self.x
self.write(self.X() + (self.fmt.string(x)))
self.x = x
if (y != None):
dy = y - self.y
self.write(self.Y() + (self.fmt.string(y)))
self.y = y
dz = (z + standoff) - self.z # In the end, we will be standoff distance above the z value passed in.
if self.drill_modal:
if z != self.prev_z:
self.write(self.Z() + (self.fmt.string(z - depth)))
self.prev_z = z
else:
self.write(self.Z() + (self.fmt.string(z - depth))) # This is the 'z' value for the bottom of the hole.
self.z = (z + standoff) # We want to remember where z is at the end (at the top of the hole)
if self.drill_modal:
if self.prev_retract != self.RETRACT(self.fmt, retract_height) :
self.write(self.RETRACT(self.fmt, retract_height))
self.prev_retract = self.RETRACT(self.fmt, retract_height)
else:
self.write(self.RETRACT(self.fmt, retract_height))
if (self.fhv) :
self.calc_feedrate_hv(math.sqrt(dx * dx + dy * dy), math.fabs(dz))
if self.drill_modal:
if (self.FEEDRATE() + self.ffmt.string(self.fv) + self.SPACE()) != self.prev_f:
self.write(self.FEEDRATE() + self.ffmt.string(self.fv) + self.SPACE())
self.prev_f = self.FEEDRATE() + self.ffmt.stirng(self.fv) + self.SPACE()
else:
self.write(self.FEEDRATE() + (self.ffmt.string(self.fv) + self.SPACE()) )
self.write_spindle()
self.write_misc()
self.write('\n')
def tool_defn(self, id, name='', radius=None, length=None, gradient=None):
def tool_defn(self, id, name='', params=None):
pass
nc.creator = Creator()

Wyświetl plik

@ -9,21 +9,18 @@ now = datetime.datetime.now()
class Creator(iso_modal.Creator):
def __init__(self):
iso_modal.Creator.__init__(self)
self.absolute_flag = True
self.prev_g91 = ''
self.useCrc = False
self.start_of_line = True
self.output_block_numbers = False
self.output_tool_definitions = False
self.output_g43_on_tool_change_line = True
def write_blocknum(self):
self.start_of_line = True
def SPACE(self):
if self.start_of_line == True:
self.start_of_line = False
return ''
else:
return ' '
def PROGRAM(self): return None
def PROGRAM_END(self): return( 'T0' + self.SPACE() + 'M06' + self.SPACE() + 'M02')
############################################################################
@ -35,257 +32,7 @@ class Creator(iso_modal.Creator):
self.write( ('(Created with emc2b post processor ' + str(now.strftime("%Y/%m/%d %H:%M")) + ')' + '\n') )
else:
self.write( ('(Created with emc2b Cutter Radius Compensation post processor ' + str(now.strftime("%Y/%m/%d %H:%M")) + ')' + '\n') )
iso_modal.Creator.program_begin(self, id, comment)
############################################################################
## Settings
def tool_defn(self, id, name='', radius=None, length=None, gradient=None):
#self.write('G43 \n')
pass
def tool_change(self, id):
self.write_blocknum()
self.write(self.SPACE() + (self.TOOL() % id) + self.SPACE() + 'G43\n')
self.t = id
def comment(self, text):
self.write_blocknum()
self.write((self.COMMENT(text) + '\n'))
# This is the coordinate system we're using. G54->G59, G59.1, G59.2, G59.3
# These are selected by values from 1 to 9 inclusive.
def workplane(self, id):
if ((id >= 1) and (id <= 6)):
self.write_blocknum()
self.write( (self.WORKPLANE() % (id + self.WORKPLANE_BASE())) + '\t (Select Relative Coordinate System)\n')
if ((id >= 7) and (id <= 9)):
self.write_blocknum()
self.write( ((self.WORKPLANE() % (6 + self.WORKPLANE_BASE())) + ('.%i' % (id - 6))) + '\t (Select Relative Coordinate System)\n')
############################################################################
## Moves
############################################################################
## Probe routines
def report_probe_results(self, x1=None, y1=None, z1=None, x2=None, y2=None, z2=None, x3=None, y3=None, z3=None, x4=None, y4=None, z4=None, x5=None, y5=None, z5=None, x6=None, y6=None, z6=None, xml_file_name=None ):
if (xml_file_name != None):
self.comment('Generate an XML document describing the probed coordinates found');
self.write_blocknum()
self.write('(LOGOPEN,')
self.write(xml_file_name)
self.write(')\n')
self.write_blocknum()
self.write('(LOG,<POINTS>)\n')
if ((x1 != None) or (y1 != None) or (z1 != None)):
self.write_blocknum()
self.write('(LOG,<POINT>)\n')
if (x1 != None):
self.write_blocknum()
self.write('#<_value>=[' + x1 + ']\n')
self.write_blocknum()
self.write('(LOG,<X>#<_value></X>)\n')
if (y1 != None):
self.write_blocknum()
self.write('#<_value>=[' + y1 + ']\n')
self.write_blocknum()
self.write('(LOG,<Y>#<_value></Y>)\n')
if (z1 != None):
self.write_blocknum()
self.write('#<_value>=[' + z1 + ']\n')
self.write_blocknum()
self.write('(LOG,<Z>#<_value></Z>)\n')
if ((x1 != None) or (y1 != None) or (z1 != None)):
self.write_blocknum()
self.write('(LOG,</POINT>)\n')
if ((x2 != None) or (y2 != None) or (z2 != None)):
self.write_blocknum()
self.write('(LOG,<POINT>)\n')
if (x2 != None):
self.write_blocknum()
self.write('#<_value>=[' + x2 + ']\n')
self.write_blocknum()
self.write('(LOG,<X>#<_value></X>)\n')
if (y2 != None):
self.write_blocknum()
self.write('#<_value>=[' + y2 + ']\n')
self.write_blocknum()
self.write('(LOG,<Y>#<_value></Y>)\n')
if (z2 != None):
self.write_blocknum()
self.write('#<_value>=[' + z2 + ']\n')
self.write_blocknum()
self.write('(LOG,<Z>#<_value></Z>)\n')
if ((x2 != None) or (y2 != None) or (z2 != None)):
self.write_blocknum()
self.write('(LOG,</POINT>)\n')
if ((x3 != None) or (y3 != None) or (z3 != None)):
self.write_blocknum()
self.write('(LOG,<POINT>)\n')
if (x3 != None):
self.write_blocknum()
self.write('#<_value>=[' + x3 + ']\n')
self.write_blocknum()
self.write('(LOG,<X>#<_value></X>)\n')
if (y3 != None):
self.write_blocknum()
self.write('#<_value>=[' + y3 + ']\n')
self.write_blocknum()
self.write('(LOG,<Y>#<_value></Y>)\n')
if (z3 != None):
self.write_blocknum()
self.write('#<_value>=[' + z3 + ']\n')
self.write_blocknum()
self.write('(LOG,<Z>#<_value></Z>)\n')
if ((x3 != None) or (y3 != None) or (z3 != None)):
self.write_blocknum()
self.write('(LOG,</POINT>)\n')
if ((x4 != None) or (y4 != None) or (z4 != None)):
self.write_blocknum()
self.write('(LOG,<POINT>)\n')
if (x4 != None):
self.write_blocknum()
self.write('#<_value>=[' + x4 + ']\n')
self.write_blocknum()
self.write('(LOG,<X>#<_value></X>)\n')
if (y4 != None):
self.write_blocknum()
self.write('#<_value>=[' + y4 + ']\n')
self.write_blocknum()
self.write('(LOG,<Y>#<_value></Y>)\n')
if (z4 != None):
self.write_blocknum()
self.write('#<_value>=[' + z4 + ']\n')
self.write_blocknum()
self.write('(LOG,<Z>#<_value></Z>)\n')
if ((x4 != None) or (y4 != None) or (z4 != None)):
self.write_blocknum()
self.write('(LOG,</POINT>)\n')
if ((x5 != None) or (y5 != None) or (z5 != None)):
self.write_blocknum()
self.write('(LOG,<POINT>)\n')
if (x5 != None):
self.write_blocknum()
self.write('#<_value>=[' + x5 + ']\n')
self.write_blocknum()
self.write('(LOG,<X>#<_value></X>)\n')
if (y5 != None):
self.write_blocknum()
self.write('#<_value>=[' + y5 + ']\n')
self.write_blocknum()
self.write('(LOG,<Y>#<_value></Y>)\n')
if (z5 != None):
self.write_blocknum()
self.write('#<_value>=[' + z5 + ']\n')
self.write_blocknum()
self.write('(LOG,<Z>#<_value></Z>)\n')
if ((x5 != None) or (y5 != None) or (z5 != None)):
self.write_blocknum()
self.write('(LOG,</POINT>)\n')
if ((x6 != None) or (y6 != None) or (z6 != None)):
self.write_blocknum()
self.write('(LOG,<POINT>)\n')
if (x6 != None):
self.write_blocknum()
self.write('#<_value>=[' + x6 + ']\n')
self.write_blocknum()
self.write('(LOG,<X>#<_value></X>)\n')
if (y6 != None):
self.write_blocknum()
self.write('#<_value>=[' + y6 + ']\n')
self.write_blocknum()
self.write('(LOG,<Y>#<_value></Y>)\n')
if (z6 != None):
self.write_blocknum()
self.write('#<_value>=[' + z6 + ']\n')
self.write_blocknum()
self.write('(LOG,<Z>#<_value></Z>)\n')
if ((x6 != None) or (y6 != None) or (z6 != None)):
self.write_blocknum()
self.write('(LOG,</POINT>)\n')
self.write_blocknum()
self.write('(LOG,</POINTS>)\n')
if (xml_file_name != None):
self.write_blocknum()
self.write('(LOGCLOSE)\n')
def open_log_file(self, xml_file_name=None ):
self.write_blocknum()
self.write('(LOGOPEN,')
self.write(xml_file_name)
self.write(')\n')
def close_log_file(self):
self.write_blocknum()
self.write('(LOGCLOSE)\n')
def log_coordinate(self, x=None, y=None, z=None):
if ((x != None) or (y != None) or (z != None)):
self.write_blocknum()
self.write('(LOG,<POINT>)\n')
if (x != None):
self.write_blocknum()
self.write('#<_value>=[' + x + ']\n')
self.write_blocknum()
self.write('(LOG,<X>#<_value></X>)\n')
if (y != None):
self.write_blocknum()
self.write('#<_value>=[' + y + ']\n')
self.write_blocknum()
self.write('(LOG,<Y>#<_value></Y>)\n')
if (z != None):
self.write_blocknum()
self.write('#<_value>=[' + z + ']\n')
self.write_blocknum()
self.write('(LOG,<Z>#<_value></Z>)\n')
if ((x != None) or (y != None) or (z != None)):
self.write_blocknum()
self.write('(LOG,</POINT>)\n')
def log_message(self, message=None ):
self.write_blocknum()
self.write('(LOG,' + message + ')\n')
nc.creator = Creator()

Wyświetl plik

@ -11,6 +11,8 @@ class Format:
self.round_down = round_down
def string(self, number):
if number == None:
return 'None'
f = float(number) * math.pow(10, self.number_of_decimal_places)
s = str(f)
@ -70,19 +72,34 @@ class Address:
if self.str == None: return ''
if self.modal:
if self.str != self.previous:
writer.write(writer.SPACE() + self.str)
writer.write(self.str)
self.previous = self.str
else:
writer.write(writer.SPACE() + self.str)
writer.write(self.str)
self.str = None
class AddressPlusMinus(Address):
def __init__(self, text, fmt = Format(), modal = True):
Address.__init__(self, text, fmt, modal)
self.str2 = None
self.previous2 = None
def set(self, number, text_plus, text_minus):
self.str = self.text + self.fmt.string(number)
Address.set(self, number)
if float(number) > 0.0:
self.str += text_plus
self.str2 = text_plus
else:
self.str += text_minus
self.str2 = text_minus
def write(self, writer):
Address.write(self, writer)
if self.str2 == None: return ''
if self.modal:
if self.str2 != self.previous2:
writer.write(writer.SPACE())
writer.write(self.str2)
self.previous2 = self.str2
else:
writer.write(writer.SPACE())
writer.write(self.str2)
self.str2 = None

Wyświetl plik

@ -8,11 +8,10 @@ class Creator(emc2.Creator):
def program_begin(self, id, comment):
self.write( ('(' + comment + ')' + '\n') )
def tool_defn(self, id, name='', radius=None, length=None, gradient=None):
def tool_defn(self, id, name='', params=None):
pass
def spindle(self, s, clockwise):
pass
nc.creator = Creator()

Wyświetl plik

@ -5,25 +5,11 @@ class Creator(iso.Creator):
def init(self):
iso.Creator.init(self)
def SPACE(self): return(' ')
def COMMENT(self,comment): return( (';%s' % comment ) )
def PROGRAM(self): return( '')
def comment(self, text):
self.write((self.COMMENT(text) + '\n'))
def program_begin(self, id, comment):
self.write( (';' + comment + '\n') )
def write_blocknum(self):
#optimise
#self.write(self.BLOCK() % self.n)
self.n += 1
def FORMAT_DWELL(self): return( self.SPACE() + self.DWELL() + ' X%f')
def SPINDLE_OFF(self): return('M05')
@ -48,9 +34,7 @@ class Creator(iso.Creator):
'''
def tool_change(self, id):
self.write_blocknum()
self.write(self.SPACE() + (self.TOOL() % id) + '\n')
self.write_blocknum()
self.write(self.SPACE() + self.s.str)
self.write('\n')
self.flush_nc()
@ -64,9 +48,7 @@ class Creator(iso.Creator):
def PROGRAM_END(self): return( 'M30')
def program_end(self):
self.write_blocknum()
self.write(self.SPACE() + self.SPINDLE_OFF() + self.SPACE() + self.PROGRAM_END() + '\n')
nc.creator = Creator()

Wyświetl plik

@ -7,34 +7,29 @@ import time
now = datetime.datetime.now()
class Creator(iso_modal.Creator):
def __init__(self):
iso_modal.Creator.__init__(self)
self.absolute_flag = True
self.prev_g91 = ''
self.useCrc = False
self.start_of_line = True
def write_blocknum(self):
self.start_of_line = True
def SPACE(self):
if self.start_of_line == True:
self.start_of_line = False
return ''
else:
return ' '
def PROGRAM_END(self): return ' '
def __init__(self):
iso_modal.Creator.__init__(self)
self.absolute_flag = True
self.prev_g91 = ''
self.useCrc = False
self.start_of_line = True
self.output_block_numbers = False
self.output_tool_definitions = False
def PROGRAM_END(self): return ' '
#optimize
def RAPID(self): return('G0')
def FEED(self): return('G1')
############################################################################
## Begin Program
def program_begin(self, id, comment):
if (self.useCrc == False):
self.write( ('(Created with grbl post processor ' + str(now.strftime("%Y/%m/%d %H:%M")) + ')' + '\n') )
else:
self.write( ('(Created with grbl Cutter Radius Compensation post processor ' + str(now.strftime("%Y/%m/%d %H:%M")) + ')' + '\n') )
def program_begin(self, id, comment):
if (self.useCrc == False):
self.write( ('(Created with grbl post processor ' + str(now.strftime("%Y/%m/%d %H:%M")) + ')' + '\n') )
else:
self.write( ('(Created with grbl Cutter Radius Compensation post processor ' + str(now.strftime("%Y/%m/%d %H:%M")) + ')' + '\n') )
@ -42,246 +37,22 @@ class Creator(iso_modal.Creator):
############################################################################
## Settings
def tool_defn(self, id, name='', radius=None, length=None, gradient=None):
pass
def tool_defn(self, id, name='', params=None):
pass
def tool_change(self, id):
pass
def tool_change(self, id):
pass
def comment(self, text):
self.write_blocknum()
self.write((self.COMMENT(text) + '\n'))
# This is the coordinate system we're using. G54->G59, G59.1, G59.2, G59.3
# These are selected by values from 1 to 9 inclusive.
def workplane(self, id):
if ((id >= 1) and (id <= 6)):
self.write_blocknum()
self.write( (self.WORKPLANE() % (id + self.WORKPLANE_BASE())) + '\t (Select Relative Coordinate System)\n')
if ((id >= 7) and (id <= 9)):
self.write_blocknum()
self.write( ((self.WORKPLANE() % (6 + self.WORKPLANE_BASE())) + ('.%i' % (id - 6))) + '\t (Select Relative Coordinate System)\n')
def workplane(self, id):
if ((id >= 1) and (id <= 6)):
self.write_blocknum()
self.write( (self.WORKPLANE() % (id + self.WORKPLANE_BASE())) + '\t (Select Relative Coordinate System)\n')
if ((id >= 7) and (id <= 9)):
self.write_blocknum()
self.write( ((self.WORKPLANE() % (6 + self.WORKPLANE_BASE())) + ('.%i' % (id - 6))) + '\t (Select Relative Coordinate System)\n')
############################################################################
## Moves
############################################################################
## Probe routines
def report_probe_results(self, x1=None, y1=None, z1=None, x2=None, y2=None, z2=None, x3=None, y3=None, z3=None, x4=None, y4=None, z4=None, x5=None, y5=None, z5=None, x6=None, y6=None, z6=None, xml_file_name=None ):
if (xml_file_name != None):
self.comment('Generate an XML document describing the probed coordinates found');
self.write_blocknum()
self.write('(LOGOPEN,')
self.write(xml_file_name)
self.write(')\n')
self.write_blocknum()
self.write('(LOG,<POINTS>)\n')
if ((x1 != None) or (y1 != None) or (z1 != None)):
self.write_blocknum()
self.write('(LOG,<POINT>)\n')
if (x1 != None):
self.write_blocknum()
self.write('#<_value>=[' + x1 + ']\n')
self.write_blocknum()
self.write('(LOG,<X>#<_value></X>)\n')
if (y1 != None):
self.write_blocknum()
self.write('#<_value>=[' + y1 + ']\n')
self.write_blocknum()
self.write('(LOG,<Y>#<_value></Y>)\n')
if (z1 != None):
self.write_blocknum()
self.write('#<_value>=[' + z1 + ']\n')
self.write_blocknum()
self.write('(LOG,<Z>#<_value></Z>)\n')
if ((x1 != None) or (y1 != None) or (z1 != None)):
self.write_blocknum()
self.write('(LOG,</POINT>)\n')
if ((x2 != None) or (y2 != None) or (z2 != None)):
self.write_blocknum()
self.write('(LOG,<POINT>)\n')
if (x2 != None):
self.write_blocknum()
self.write('#<_value>=[' + x2 + ']\n')
self.write_blocknum()
self.write('(LOG,<X>#<_value></X>)\n')
if (y2 != None):
self.write_blocknum()
self.write('#<_value>=[' + y2 + ']\n')
self.write_blocknum()
self.write('(LOG,<Y>#<_value></Y>)\n')
if (z2 != None):
self.write_blocknum()
self.write('#<_value>=[' + z2 + ']\n')
self.write_blocknum()
self.write('(LOG,<Z>#<_value></Z>)\n')
if ((x2 != None) or (y2 != None) or (z2 != None)):
self.write_blocknum()
self.write('(LOG,</POINT>)\n')
if ((x3 != None) or (y3 != None) or (z3 != None)):
self.write_blocknum()
self.write('(LOG,<POINT>)\n')
if (x3 != None):
self.write_blocknum()
self.write('#<_value>=[' + x3 + ']\n')
self.write_blocknum()
self.write('(LOG,<X>#<_value></X>)\n')
if (y3 != None):
self.write_blocknum()
self.write('#<_value>=[' + y3 + ']\n')
self.write_blocknum()
self.write('(LOG,<Y>#<_value></Y>)\n')
if (z3 != None):
self.write_blocknum()
self.write('#<_value>=[' + z3 + ']\n')
self.write_blocknum()
self.write('(LOG,<Z>#<_value></Z>)\n')
if ((x3 != None) or (y3 != None) or (z3 != None)):
self.write_blocknum()
self.write('(LOG,</POINT>)\n')
if ((x4 != None) or (y4 != None) or (z4 != None)):
self.write_blocknum()
self.write('(LOG,<POINT>)\n')
if (x4 != None):
self.write_blocknum()
self.write('#<_value>=[' + x4 + ']\n')
self.write_blocknum()
self.write('(LOG,<X>#<_value></X>)\n')
if (y4 != None):
self.write_blocknum()
self.write('#<_value>=[' + y4 + ']\n')
self.write_blocknum()
self.write('(LOG,<Y>#<_value></Y>)\n')
if (z4 != None):
self.write_blocknum()
self.write('#<_value>=[' + z4 + ']\n')
self.write_blocknum()
self.write('(LOG,<Z>#<_value></Z>)\n')
if ((x4 != None) or (y4 != None) or (z4 != None)):
self.write_blocknum()
self.write('(LOG,</POINT>)\n')
if ((x5 != None) or (y5 != None) or (z5 != None)):
self.write_blocknum()
self.write('(LOG,<POINT>)\n')
if (x5 != None):
self.write_blocknum()
self.write('#<_value>=[' + x5 + ']\n')
self.write_blocknum()
self.write('(LOG,<X>#<_value></X>)\n')
if (y5 != None):
self.write_blocknum()
self.write('#<_value>=[' + y5 + ']\n')
self.write_blocknum()
self.write('(LOG,<Y>#<_value></Y>)\n')
if (z5 != None):
self.write_blocknum()
self.write('#<_value>=[' + z5 + ']\n')
self.write_blocknum()
self.write('(LOG,<Z>#<_value></Z>)\n')
if ((x5 != None) or (y5 != None) or (z5 != None)):
self.write_blocknum()
self.write('(LOG,</POINT>)\n')
if ((x6 != None) or (y6 != None) or (z6 != None)):
self.write_blocknum()
self.write('(LOG,<POINT>)\n')
if (x6 != None):
self.write_blocknum()
self.write('#<_value>=[' + x6 + ']\n')
self.write_blocknum()
self.write('(LOG,<X>#<_value></X>)\n')
if (y6 != None):
self.write_blocknum()
self.write('#<_value>=[' + y6 + ']\n')
self.write_blocknum()
self.write('(LOG,<Y>#<_value></Y>)\n')
if (z6 != None):
self.write_blocknum()
self.write('#<_value>=[' + z6 + ']\n')
self.write_blocknum()
self.write('(LOG,<Z>#<_value></Z>)\n')
if ((x6 != None) or (y6 != None) or (z6 != None)):
self.write_blocknum()
self.write('(LOG,</POINT>)\n')
self.write_blocknum()
self.write('(LOG,</POINTS>)\n')
if (xml_file_name != None):
self.write_blocknum()
self.write('(LOGCLOSE)\n')
def open_log_file(self, xml_file_name=None ):
self.write_blocknum()
self.write('(LOGOPEN,')
self.write(xml_file_name)
self.write(')\n')
def close_log_file(self):
self.write_blocknum()
self.write('(LOGCLOSE)\n')
def log_coordinate(self, x=None, y=None, z=None):
if ((x != None) or (y != None) or (z != None)):
self.write_blocknum()
self.write('(LOG,<POINT>)\n')
if (x != None):
self.write_blocknum()
self.write('#<_value>=[' + x + ']\n')
self.write_blocknum()
self.write('(LOG,<X>#<_value></X>)\n')
if (y != None):
self.write_blocknum()
self.write('#<_value>=[' + y + ']\n')
self.write_blocknum()
self.write('(LOG,<Y>#<_value></Y>)\n')
if (z != None):
self.write_blocknum()
self.write('#<_value>=[' + z + ']\n')
self.write_blocknum()
self.write('(LOG,<Z>#<_value></Z>)\n')
if ((x != None) or (y != None) or (z != None)):
self.write_blocknum()
self.write('(LOG,</POINT>)\n')
def log_message(self, message=None ):
self.write_blocknum()
self.write('(LOG,' + message + ')\n')
nc.creator = Creator()

Wyświetl plik

@ -64,7 +64,6 @@ class Creator(nc.Creator):
self.arc_centre_absolute = False
self.arc_centre_positive = False
self.in_quadrant_splitting = False
self.machine_coordinates = False
self.drillExpanded = False
self.can_do_helical_arcs = True
self.shift_x = 0.0
@ -75,7 +74,6 @@ class Creator(nc.Creator):
def SPACE(self): return('')
def FORMAT_FEEDRATE(self): return('%.2f')
def FEEDRATE(self): return((self.SPACE() + ' F'))
def FORMAT_ANG(self): return('%.1f')
def FORMAT_TIME(self): return('%.2f')
def FORMAT_DWELL(self): return('P%f')
@ -158,7 +156,7 @@ class Creator(nc.Creator):
## Internals
def write_feedrate(self):
pass;#self.f.write(self)
self.f.write(self)
def write_preps(self):
self.g_plane.write(self)
@ -281,16 +279,16 @@ class Creator(nc.Creator):
self.write(self.SPACE() + (self.TOOL() % id) + '\n')
self.t = id
def tool_defn(self, id, name='', radius=None, length=None, gradient=None):
def tool_defn(self, id, name='', params=None):
self.write_blocknum()
self.write(self.SPACE() + self.TOOL_DEFINITION())
self.write(self.SPACE() + ('P%i' % id) + ' ')
if (radius != None):
self.write(self.SPACE() + ('R%.3f' % radius))
self.write(self.SPACE() + ('R%.3f' % (float(params['diameter'])/2)))
if (length != None):
self.write(self.SPACE() + 'Z%.3f' % length)
self.write(self.SPACE() + 'Z%.3f' % float(params['cutting edge height']))
self.write('\n')
@ -300,6 +298,9 @@ class Creator(nc.Creator):
def offset_length(self, id, length=None):
pass
def current_tool(self):
return self.t
############################################################################
## Datums
@ -356,12 +357,9 @@ class Creator(nc.Creator):
############################################################################
## Moves
def rapid(self, x=None, y=None, z=None, a=None, b=None, c=None, machine_coordinates=None ):
def rapid(self, x=None, y=None, z=None, a=None, b=None, c=None ):
self.write_blocknum()
if self.machine_coordinates != False or (machine_coordinates != None and machine_coordinates == True):
self.write( self.MACHINE_COORDINATES() + self.SPACE() )
if self.g0123_modal:
if self.prev_g0123 != self.RAPID():
self.write(self.SPACE() + self.RAPID())
@ -420,7 +418,7 @@ class Creator(nc.Creator):
self.write_misc()
self.write('\n')
def feed(self, x=None, y=None, z=None):
def feed(self, x=None, y=None, z=None, a=None, b=None, c=None):
if self.same_xyz(x, y, z): return
self.write_blocknum()
if self.g0123_modal:
@ -676,7 +674,7 @@ class Creator(nc.Creator):
self.write_misc()
self.write('\n')
def rapid_home(self, x=None, y=None, z=None, a=None, b=None, c=None, machine_coordinates=None):
def rapid_home(self, x=None, y=None, z=None, a=None, b=None, c=None):
pass
def rapid_unhome(self):
@ -739,7 +737,7 @@ class Creator(nc.Creator):
# revert it. I must set the mode so that I can be sure the values I'm passing in make
# sense to the end-machine.
#
def drill(self, x=None, y=None, z=None, depth=None, standoff=None, dwell=None, peck_depth=None, retract_mode=None, spindle_mode=None):
def drill(self, x=None, y=None, dwell=None, depthparams = None, retract_mode=None, spindle_mode=None, internal_coolant_on=None, rapid_to_clearance = None):
if (standoff == None):
# This is a bad thing. All the drilling cycles need a retraction (and starting) height.
return

Wyświetl plik

@ -61,7 +61,7 @@ class Creator(nc.Creator):
machine_y = self.closest_int(y * self.units_to_mc_units)
return machine_x, machine_y
def rapid(self, x=None, y=None, z=None, a=None, b=None, c=None, machine_coordinates=None):
def rapid(self, x=None, y=None, z=None, a=None, b=None, c=None):
# ignore the z, any rapid will be assumed to be done with the pen up
mx, my = self.get_machine_x_y(x, y)
if mx != self.x or my != self.y:
@ -69,7 +69,7 @@ class Creator(nc.Creator):
self.x = mx
self.y = my
def feed(self, x=None, y=None, z=None):
def feed(self, x=None, y=None, z=None, a=None, b=None, c=None):
# ignore the z, any feed will be assumed to be done with the pen down
mx, my = self.get_machine_x_y(x, y)
if mx != self.x or my != self.y:

Wyświetl plik

@ -37,7 +37,7 @@ class Creator(hpgl2d.Creator):
machine_z = self.closest_int(z * self.units_to_mc_units)
return machine_x, machine_y, machine_z
def rapid(self, x=None, y=None, z=None, a=None, b=None, c=None, machine_coordinates=None):
def rapid(self, x=None, y=None, z=None, a=None, b=None, c=None):
# do a rapid move.
# for now, do all rapid moves at V50 ( 50 mm/s )
mx, my, mz = self.get_machine_xyz(x, y, z)
@ -49,7 +49,7 @@ class Creator(hpgl2d.Creator):
self.z = mz
self.doing_rapid = True
def feed(self, x=None, y=None, z=None):
def feed(self, x=None, y=None, z=None, a=None, b=None, c=None):
# do a feed move.
# for now, do all feed moves at V10 ( 10 mm/s )
mx, my, mz = self.get_machine_xyz(x, y, z)

Wyświetl plik

@ -1,3 +1,4 @@
class Codes():
pass
codes = Codes()

Wyświetl plik

@ -66,11 +66,6 @@ class CreatorIso(nc.Creator):
def write_misc(self):
if (len(self.m)) : self.write(self.m.pop())
def write_blocknum(self):
self.write(iso.codes.BLOCK() % self.n)
self.write(iso.codes.SPACE())
self.n += 10
def write_spindle(self):
self.write(self.s)
self.s = ''
@ -83,7 +78,6 @@ class CreatorIso(nc.Creator):
self.write('\n')
def program_stop(self, optional=False):
self.write_blocknum()
if (optional) :
self.write(iso.codes.STOP_OPTIONAL() + '\n')
self.prev_g0123 = ''
@ -93,12 +87,10 @@ class CreatorIso(nc.Creator):
def program_end(self):
self.write_blocknum()
self.write(iso.codes.PROGRAM_END() + '\n')
def flush_nc(self):
if len(self.g) == 0 and len(self.m) == 0: return
self.write_blocknum()
self.write_preps()
self.write_misc()
self.write('\n')
@ -111,11 +103,9 @@ class CreatorIso(nc.Creator):
self.write('\n')
def sub_call(self, id):
self.write_blocknum()
self.write((iso.codes.SUBPROG_CALL() % id) + '\n')
def sub_end(self):
self.write_blocknum()
self.write(iso.codes.SUBPROG_END() + '\n')
############################################################################
@ -130,12 +120,10 @@ class CreatorIso(nc.Creator):
self.fmt = iso.codes.FORMAT_MM()
def absolute(self):
#self.write_blocknum()
self.g += iso.codes.ABSOLUTE()
self.absolute_flag = True
def incremental(self):
#self.write_blocknum()
self.g += iso.codes.INCREMENTAL()
self.absolute_flag = False
@ -149,7 +137,6 @@ class CreatorIso(nc.Creator):
elif (plane == 2) : self.g += iso.codes.PLANE_YZ()
def set_temporary_origin(self, x=None, y=None, z=None, a=None, b=None, c=None):
self.write_blocknum()
self.write((iso.codes.SET_TEMPORARY_COORDINATE_SYSTEM()))
if (x != None): self.write( iso.codes.SPACE() + 'X ' + (self.fmt % x) )
if (y != None): self.write( iso.codes.SPACE() + 'Y ' + (self.fmt % y) )
@ -160,7 +147,6 @@ class CreatorIso(nc.Creator):
self.write('\n')
def remove_temporary_origin(self):
self.write_blocknum()
self.write((iso.codes.REMOVE_TEMPORARY_COORDINATE_SYSTEM()))
self.write('\n')
@ -168,23 +154,11 @@ class CreatorIso(nc.Creator):
## Tools
def tool_change(self, id):
self.write_blocknum()
self.write((iso.codes.TOOL() % id) + '\n')
self.t = id
def tool_defn(self, id, name='', radius=None, length=None, gradient=None):
def tool_defn(self, id, name='', params=None):
pass
self.write_blocknum()
self.write(iso.codes.TOOL_DEFINITION())
self.write(('P%i' % id) + ' ')
if (radius != None):
self.write(('R%.3f' % radius) + ' ')
if (length != None):
self.write('Z%.3f' % length)
self.write('\n')
def offset_radius(self, id, radius=None):
pass
@ -251,7 +225,7 @@ class CreatorIso(nc.Creator):
############################################################################
## Moves
def rapid(self, x=None, y=None, z=None, a=None, b=None, c=None, machine_coordinates=None ):
def rapid(self, x=None, y=None, z=None, a=None, b=None, c=None):
self.write_blocknum()
if self.g0123_modal:
if self.prev_g0123 != iso.codes.RAPID():
@ -317,7 +291,7 @@ class CreatorIso(nc.Creator):
self.write_misc()
self.write('\n')
def feed(self, x=None, y=None, z=None):
def feed(self, x=None, y=None, z=None, a=None, b=None, c=None):
if self.same_xyz(x, y, z): return
self.write_blocknum()
if self.g0123_modal:

Wyświetl plik

@ -17,12 +17,6 @@ class Creator(iso.Creator):
def program_begin(self, id, comment):
self.write( ('') )
#def write_blocknum(self):
# #optimise
#self.write(self.BLOCK() % self.n)
# self.n += 1
def FORMAT_DWELL(self): return( self.SPACE() + self.DWELL() + ' X%f')
def SPINDLE_CW(self): return('M03')
@ -75,4 +69,3 @@ class Creator(iso.Creator):
nc.creator = Creator()

Wyświetl plik

@ -12,11 +12,8 @@ class Creator(iso.Creator):
self.write( ('(' + comment + ')' + '\n') )
def tool_change(self, id):
self.write_blocknum()
self.write('G43H%i'% id +'\n')
self.write_blocknum()
self.write((self.TOOL() % id) + '\n')
self.t = id
nc.creator = Creator()

Wyświetl plik

@ -116,12 +116,12 @@ class CreatorMakerbotHBP(iso_modal.CreatorIsoModal):
# self.write((maker.codes.TOOL() % id) + '\n')
# self.t = id
def tool_defn(self, id, name='', radius=None, length=None, gradient=None):
def tool_defn(self, id, name='', params=None):
pass
############################################################################
## Moves
def rapid(self, x=None, y=None, z=None, a=None, b=None, c=None, machine_coordinates=None ):
def rapid(self, x=None, y=None, z=None, a=None, b=None, c=None):
self.write_blocknum()
if self.g0123_modal:
if self.prev_g0123 != maker.codes.RAPID():
@ -181,7 +181,7 @@ class CreatorMakerbotHBP(iso_modal.CreatorIsoModal):
self.write_misc()
self.write('\n')
def feed(self, x=None, y=None, z=None):
def feed(self, x=None, y=None, z=None, a=None, b=None, c=None):
if self.same_xyz(x, y, z): return
self.write_blocknum()
if self.g0123_modal:
@ -303,4 +303,3 @@ class CreatorMakerbotHBP(iso_modal.CreatorIsoModal):
self.prev_g0123 = ''
nc.creator = CreatorMakerbotHBP()

Wyświetl plik

@ -32,7 +32,8 @@ class Creator:
def file_open(self, name):
#self.buffer=[]
self.file = open(name, 'w')
self.filename = name
def file_close(self):
#self.file.write(''.join(self.buffer))
#self.buffer=[]
@ -55,6 +56,9 @@ class Creator:
"""Begin a program"""
pass
def add_stock(self, type_name, params):
pass
def program_stop(self, optional=False):
"""Stop the machine"""
pass
@ -124,7 +128,7 @@ class Creator:
"""Change the tool"""
pass
def tool_defn(self, id, name='', radius=None, length=None, gradient=None):
def tool_defn(self, id, name='', params=None):
"""Define a tool"""
pass
@ -136,6 +140,9 @@ class Creator:
"""Set tool length offsetting"""
pass
def current_tool(self):
return None
############################################################################
## Datums
@ -209,11 +216,11 @@ class Creator:
############################################################################
## Moves
def rapid(self, x=None, y=None, z=None, a=None, b=None, c=None, machine_coordinates=None):
def rapid(self, x=None, y=None, z=None, a=None, b=None, c=None):
"""Rapid move"""
pass
def feed(self, x=None, y=None, z=None):
def feed(self, x=None, y=None, z=None, a = None, b = None, c = None):
"""Feed move"""
pass
@ -263,7 +270,7 @@ class Creator:
"""Profile routine"""
pass
def drill(self, x=None, y=None, z=None, depth=None, standoff=None, dwell=None, peck_depth=None, retract_mode=None, spindle_mode=None):
def drill(self, x=None, y=None, dwell=None, depthparams = None, retract_mode=None, spindle_mode=None, internal_coolant_on=None, rapid_to_clearance=None):
"""Drilling routines"""
pass
@ -413,6 +420,9 @@ def output(filename):
def program_begin(id, name=''):
creator.program_begin(id, name)
def add_stock(type_name, params):
creator.add_stock(type_name, params)
def program_stop(optional=False):
creator.program_stop(optional)
@ -467,8 +477,8 @@ def remove_temporary_origin():
def tool_change(id):
creator.tool_change(id)
def tool_defn(id, name='', radius=None, length=None, gradient=None):
creator.tool_defn(id, name, radius, length, gradient)
def tool_defn(id, name='', params=None):
creator.tool_defn(id, name, params)
def offset_radius(id, radius=None):
creator.offset_radius(id, radius)
@ -476,6 +486,9 @@ def offset_radius(id, radius=None):
def offset_length(id, length=None):
creator.offset_length(id, length)
def current_tool(self):
return creator.current_tool()
############################################################################
## Datums
@ -540,10 +553,10 @@ def gearrange(gear=0):
############################################################################
## Moves
def rapid(x=None, y=None, z=None, a=None, b=None, c=None, machine_coordinates=None):
creator.rapid(x, y, z, a, b, c, machine_coordinates)
def rapid(x=None, y=None, z=None, a=None, b=None, c=None):
creator.rapid(x, y, z, a, b, c)
def feed(x=None, y=None, z=None):
def feed(x=None, y=None, z=None, a = None, b = None, c = None):
creator.feed(x, y, z)
def arc_cw(x=None, y=None, z=None, i=None, j=None, k=None, r=None):
@ -591,8 +604,8 @@ def pocket():
def profile():
creator.profile()
def drill(x=None, y=None, z=None, depth=None, standoff=None, dwell=None, peck_depth=None, retract_mode=None, spindle_mode=None):
creator.drill(x, y, z, depth, standoff, dwell, peck_depth, retract_mode, spindle_mode)
def drill(x=None, y=None, dwell=None, depthparams = None, retract_mode=None, spindle_mode=None, internal_coolant_on=None, rapid_to_clearance=None):
creator.drill(x, y, dwell, depthparams, retract_mode, spindle_mode, internal_coolant_on, rapid_to_clearance)
def tap(x=None, y=None, z=None, zretract=None, depth=None, standoff=None, dwell_bottom=None, pitch=None, stoppos=None, spin_in=None, spin_out=None, tap_mode=None, direction=None):
@ -693,5 +706,3 @@ def build_bed_temp(temp=None):
def chamber_temp(temp=None):
creator.chamber_temp(temp)

Wyświetl plik

@ -13,7 +13,7 @@ class CreatorPrintbot(iso_modal.CreatorIsoModal):
def __init__(self):
iso_modal.CreatorIsoModal.__init__(self)
def tool_defn(self, id, name='', radius=None, length=None, gradient=None):
def tool_defn(self, id, name='', params=None):
pass
def write_blocknum(self):
@ -45,7 +45,7 @@ class CreatorPrintbot(iso_modal.CreatorIsoModal):
# do a G1 even for rapid moves
iso_modal.CreatorIsoModal.feed(self, x, y, z)
def feed(self, x=None, y=None, z=None):
def feed(self, x=None, y=None, z=None, a=None, b=None, c=None):
iso_modal.CreatorIsoModal.feed(self, x, y, z)
################################################################################

Wyświetl plik

@ -1,4 +1,4 @@
from . import nc
import nc
units = 1.0
@ -8,14 +8,34 @@ class Redirector(nc.Creator):
nc.Creator.__init__(self)
self.original = original
self.x = original.x * units
self.y = original.y * units
self.z = original.z * units
self.x = None
self.y = None
self.z = None
if original.x != None: self.x = original.x * units
if original.y != None: self.y = original.y * units
if original.z != None: self.z = original.z * units
self.imperial = False
def cut_path(self):
pass
############################################################################
## Programs
def write(self, s):
self.original.write(s)
def output_fixture(self):
self.original.output_fixture()
def increment_fixture(self):
self.original.increment_fixture()
def get_fixture(self):
return self.original.get_fixture()
def set_fixture(self, fixture):
self.original.set_fixture(fixture)
def program_begin(self, id, name=''):
self.cut_path()
self.original.program_begin(id, name)
@ -35,7 +55,7 @@ class Redirector(nc.Creator):
############################################################################
## Subprograms
def sub_begin(self, id, name=''):
def sub_begin(self, id, name=None):
self.cut_path()
self.original.sub_begin(id, name)
@ -46,6 +66,12 @@ class Redirector(nc.Creator):
def sub_end(self):
self.cut_path()
self.original.sub_end()
def disable_output(self):
self.original.disable_output()
def enable_output(self):
self.original.enable_output()
############################################################################
## Settings
@ -90,9 +116,9 @@ class Redirector(nc.Creator):
self.cut_path()
self.original.tool_change(id)
def tool_defn(self, id, name='', radius=None, length=None, gradient=None):
def tool_defn(self, id, name='', params=None):
self.cut_path()
self.original.tool_defn(id, name, radius, length, gradient)
self.original.tool_defn(id, name, params)
def offset_radius(self, id, radius=None):
self.cut_path()
@ -143,9 +169,9 @@ class Redirector(nc.Creator):
############################################################################
## Moves
def rapid(self, x=None, y=None, z=None, a=None, b=None, c=None, machine_coordinates=None):
def rapid(self, x=None, y=None, z=None, a=None, b=None, c=None):
self.cut_path()
self.original.rapid(x, y, z, a, b, c, machine_coordinates)
self.original.rapid(x, y, z, a, b, c)
if x != None: self.x = x * units
if y != None: self.y = y * units
if z != None: self.z = z * units
@ -156,7 +182,7 @@ class Redirector(nc.Creator):
def z2(self, z):
return z
def feed(self, x=None, y=None, z=None):
def feed(self, x=None, y=None, z=None, a = None, b = None, c = None):
px = self.x
py = self.y
pz = self.z
@ -221,7 +247,10 @@ class Redirector(nc.Creator):
def pattern(self):
self.cut_path()
self.original.pattern()
def pattern_uses_subroutine(self):
return self.original.pattern_uses_subroutine()
def pocket(self):
self.cut_path()
self.original.pocket()
@ -234,9 +263,9 @@ class Redirector(nc.Creator):
self.cut_path()
self.circular_pocket(x, y, ToolDiameter, HoleDiameter, ClearanceHeight, StartHeight, MaterialTop, FeedRate, SpindleRPM, HoleDepth, DepthOfCut, StepOver)
def drill(self, x=None, y=None, z=None, depth=None, standoff=None, dwell=None, peck_depth=None,retract_mode=None, spindle_mode=None):
def drill(self, x=None, y=None, dwell=None, depthparams = None, retract_mode=None, spindle_mode=None, internal_coolant_on=None, rapid_to_clearance=None):
self.cut_path()
self.original.drill(x, y, z, depth, standoff, dwell, peck_depth, retract_mode, spindle_mode)
self.original.drill(x, y, dwell, depthparams, spindle_mode, internal_coolant_on, rapid_to_clearance)
# argument list adapted for compatibility with Tapping module
# wild guess - I'm unsure about the purpose of this file and wether this works -haberlerm
@ -249,6 +278,9 @@ class Redirector(nc.Creator):
self.cut_path()
self.original.bore(x, y, self.z2(z), self.z2(zretract), depth, standoff, dwell_Bottom, feed_in, feed_out, stoppos, shift_back, shift_right, backbore, stop)
def end_canned_cycle(self):
self.original.end_canned_cycle()
############################################################################
## Misc
@ -263,4 +295,6 @@ class Redirector(nc.Creator):
def variable_set(self, id, value):
self.cut_path()
self.original.variable_set(id, value)
def set_ocl_cutter(self, cutter):
self.original.set_ocl_cutter(cutter)

Wyświetl plik

@ -163,26 +163,15 @@ class Creator(nc.Creator):
#self.write_blocknum()
#self.write((iso.TOOL % id) + '\n')
#self.write('\n')
pass
def tool_defn(self, id, name='', radius=None, length=None, gradient=None):
#self.write_blocknum()
#self.write(iso.TOOL_DEFINITION)
#self.write(('P%i' % id) + ' ')
#if (radius != None):
# self.write(('R%.3f' % radius) + ' ')
#if (length != None):
# self.write('Z%.3f' % length)
#self.write('\n')
pass
pass
def tool_defn(self, id, name='', params=None):
pass
def offset_radius(self, id, radius=None):
pass
pass
def offset_length(self, id, length=None):
pass
pass
############################################################################
## Datums
@ -492,7 +481,7 @@ class Creator(nc.Creator):
# revert it. I must set the mode so that I can be sure the values I'm passing in make
# sense to the end-machine.
#
def drill(self, x=None, y=None, z=None, depth=None, standoff=None, dwell=None, peck_depth=None,retract_mode=None, spindle_mode=None):
def drill(self, x=None, y=None, dwell=None, depthparams = None, retract_mode=None, spindle_mode=None, internal_coolant_on=None, rapid_to_clearance=None):
if (standoff == None):
# This is a bad thing. All the drilling cycles need a retraction (and starting) height.
return

Wyświetl plik

@ -12,7 +12,7 @@ class Creator(iso_modal.Creator):
self.can_do_helical_arcs = False
self.fmt.number_of_decimal_places = 2
def tool_defn(self, id, name='', radius=None, length=None, gradient=None):
def tool_defn(self, id, name='', params=None):
pass
def dwell(self, t):

Wyświetl plik

@ -147,7 +147,7 @@ class Creator(nc.Creator):
############################################################################
## Moves
def rapid(self, x=None, y=None, z=None, a=None, b=None, c=None, machine_coordinates=None ):
def rapid(self, x=None, y=None, z=None, a=None, b=None, c=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)))

Wyświetl plik

@ -15,9 +15,8 @@ class Creator(iso_modal.Creator):
def __init__(self):
iso_modal.Creator.__init__(self)
self.output_tool_definitions = False
def tool_defn(self, id, name='', radius=None, length=None, gradient=None):
pass
################################################################################

Wyświetl plik

@ -52,7 +52,7 @@ class Creator(iso_modal.Creator):
# no tool definition lines wanted
def tool_defn(self, id, name='', radius=None, length=None, gradient=None):
def tool_defn(self, id, name='', params=None):
pass
# no comments wanted

Wyświetl plik

@ -50,7 +50,7 @@ class Creator(iso_modal.Creator):
############################################################################
## Settings
def tool_defn(self, id, name='', radius=None, length=None, gradient=None):
def tool_defn(self, id, name='', params=None):
#self.write('G43 \n')
pass
@ -316,4 +316,4 @@ class Creator(iso_modal.Creator):
self.write_blocknum()
self.write('(LOG,' + message + ')\n')
nc.creator = Creator()
nc.creator = Creator()