Advertisement
danfalck

heeks_funcs.py

Nov 12th, 2014
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.42 KB | None | 0 0
  1. import sys
  2. sys.path.insert(0,'/usr/lib/heekscnc/')
  3. from nc.nc import *
  4. import nc.centroid1
  5. import kurve_funcs
  6. import area
  7. area.set_units(25.4)
  8.  
  9. #######################################################
  10. # drilling function
  11. def drillholes(holeList,paramaters,keepdrilling=False):
  12.     feedrate_hv(paramaters['verticalfeedrate'],paramaters['horizontalfeedrate'])
  13.     #x, y = holeList
  14.     z=0
  15.     depth=paramaters['depth']
  16.     standoff=paramaters['standoff']
  17.     dwell=paramaters['dwell']
  18.     peck_depth=paramaters['peck_depth']
  19.     retract_mode=paramaters['retract_mode']
  20.     spindle_mode=paramaters['spindle_mode']
  21.     for i in holeList:
  22.         x,y = i[0],i[1]
  23.         drill(x, y, z, depth, standoff, dwell, peck_depth, retract_mode, spindle_mode)
  24.     if keepdrilling:
  25.         pass
  26.     else:
  27.         end_canned_cycle()
  28.  
  29. #######################################################
  30. # profiling function
  31.  
  32. def profile(curve_name, profileparams,startparams):
  33.     feedrate_hv(profileparams['verticalfeedrate'],profileparams['horizontalfeedrate'])
  34.     side = profileparams['side']
  35.     tool_diameter = profileparams['tooldiameter']
  36.     offset_extra = profileparams['offset_extra']
  37.     roll_radius = profileparams['roll_radius']
  38.     roll_on = profileparams['roll_on']
  39.     roll_off = profileparams['roll_off']
  40.     rapid_safety_space = profileparams['rapid_safety_space']
  41.     clearance = profileparams['clearance']
  42.     start_depth = profileparams['start_depth']
  43.     step_down = profileparams['step_down']
  44.     final_depth = profileparams['final_depth']
  45.     extend_at_start = profileparams['extend_at_start']
  46.     extend_at_end = profileparams['extend_at_end']
  47.     lead_in_line_len = profileparams['lead_in_line_len']
  48.     lead_out_line_len = profileparams['lead_out_line_len']
  49.  
  50.     if startparams['startpt']:
  51.         kurve_funcs.make_smaller( curve_name, start = area.Point(startparams['startptX'] ,startparams['startptY']))
  52.    
  53.     kurve_funcs.profile(curve_name, side, tool_diameter/2, offset_extra, roll_radius, roll_on, roll_off, rapid_safety_space, clearance, start_depth, step_down, final_depth,extend_at_start,extend_at_end,lead_in_line_len,lead_out_line_len )
  54.  
  55. #######################################################
  56.  
  57. # helical hole cutting
  58.  
  59. #use the next function for cutting out round holes -ie strap button holes
  60. from math import fabs
  61. def helical_hole(xPos, yPos, dia,  final_depth, clearance, step_down, step_over, tool_dia, start_depth):
  62.     '''
  63.    helical bore routine - no cutter comp
  64.    '''
  65.     if (tool_dia > dia):
  66.         raise "tool wider than inner bore diameter"
  67.  
  68.     if (step_over > fabs(yPos+dia/2.0- tool_dia/2.0)):
  69.         raise "step over too big"
  70.     ydelta_plus = yPos + step_over  
  71.     ydelta_minus = yPos - step_over  
  72.     rapid(z=clearance)
  73.     rapid(x=xPos,y=yPos-step_over )    
  74.     currentDepth = start_depth-step_down
  75.     arc_ccw(x=xPos,y=ydelta_plus,z=(start_depth),i=xPos,j=yPos)
  76.     while currentDepth >= final_depth :      
  77.         ydelta = 0.0
  78.         ydelta_plus = yPos + step_over  
  79.         ydelta_minus = yPos - step_over                  
  80.         feed(y= ydelta_plus )
  81.         yPos2 = yPos        
  82.         arc_ccw(x=xPos,y=ydelta_minus,z=(currentDepth+step_down/2.0),i=xPos,j=yPos2)      
  83.         arc_ccw(x=xPos,y=ydelta_plus,z=(currentDepth),i=xPos,j=yPos)
  84.         while ydelta < ((dia/2.0 - tool_dia/2.0)-step_over):
  85.  
  86.             arc_ccw(x=xPos,y=ydelta_minus,i=xPos,j=yPos2)
  87.             arc_ccw(x=xPos,y=ydelta_plus,i=xPos,j=yPos)
  88.             temp = ydelta_plus
  89.             ydelta= ydelta + step_over
  90.             ydelta_plus= yPos  + ydelta +step_over
  91.             ydelta_minus= yPos  - ydelta -step_over
  92.             yPos2 = yPos-step_over/2.0
  93.            
  94.         midpoint = ((temp - (yPos-dia/2.0+ tool_dia/2.0))*.5) + (yPos-dia/2.0+ tool_dia/2.0)        
  95.         arc_ccw(x=xPos,y=(yPos-dia/2.0+ tool_dia/2.0),i=xPos,j=midpoint)
  96.         arc_ccw(x=xPos,y=(yPos+dia/2.0- tool_dia/2.0),i=xPos,j=yPos)
  97.         arc_ccw(x=xPos,y=(yPos-dia/2.0+ tool_dia/2.0),i=xPos,j=yPos)        
  98.         feed(xPos,yPos)        
  99.         currentDepth = currentDepth - step_down
  100.     ydelta = 0
  101.     ydelta_plus = yPos + step_over  
  102.     ydelta_minus = yPos - step_over
  103.  
  104.     if currentDepth > final_depth :
  105.         ydelta = 0.0
  106.         ydelta_plus = yPos + step_over  
  107.         ydelta_minus = yPos - step_over                  
  108.         feed(y= ydelta_plus )
  109.         yPos2 = yPos        
  110.         arc_ccw(x=xPos,y=ydelta_minus,z=(final_depth+step_down/2.0),i=xPos,j=yPos2)      
  111.         arc_ccw(x=xPos,y=ydelta_plus,z=(final_depth),i=xPos,j=yPos)
  112.         while ydelta < ((dia/2.0 - tool_dia/2.0)-step_over):
  113.  
  114.             arc_ccw(x=xPos,y=ydelta_minus,i=xPos,j=yPos2)
  115.             arc_ccw(x=xPos,y=ydelta_plus,i=xPos,j=yPos)
  116.             temp = ydelta_plus
  117.             ydelta= ydelta + step_over
  118.             ydelta_plus= yPos  + ydelta +step_over
  119.  
  120.             ydelta_minus= yPos  - ydelta -step_over
  121.             yPos2 = yPos-step_over/2.0          
  122.         midpoint = ((temp - (yPos-dia/2.0+ tool_dia/2.0))*.5) + (yPos-dia/2.0+ tool_dia/2.0)        
  123.         arc_ccw(x=xPos,y=(yPos-dia/2.0+ tool_dia/2.0),i=xPos,j=midpoint)
  124.         arc_ccw(x=xPos,y=(yPos+dia/2.0- tool_dia/2.0),i=xPos,j=yPos)
  125.         arc_ccw(x=xPos,y=(yPos-dia/2.0+ tool_dia/2.0),i=xPos,j=yPos)
  126.  
  127.     else:
  128.         feed(xPos,yPos)      
  129.  
  130.     feed(xPos,yPos)        
  131.     rapid(z=clearance)
  132.  
  133. #######################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement