Advertisement
danfalck

cncOps.py

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