danfalck

freecad_read.py

Oct 21st, 2011
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 20.06 KB | None | 0 0
  1. ################################################################################
  2.  
  3. # graphite_read.py
  4.  
  5. #
  6.  
  7. # Base class for NC code parsing into FreeCAD
  8.  
  9. #
  10.  
  11. # Dan Falck, 2011-10-21
  12.  
  13.  
  14.  
  15. ################################################################################
  16.  
  17. import geom2d as g2d
  18.  
  19.  
  20.  
  21.  
  22.  
  23. #coords = Save(repr(0),repr(0),repr(0))        
  24.  
  25. class Save:
  26.  
  27.     def __init__(self, str1,str2,str3):
  28.  
  29.    
  30.  
  31.       self.x = str1
  32.  
  33.       self.y = str2
  34.  
  35.       self.z = str3
  36.  
  37.   # Two methods:
  38.  
  39.     def show(self):
  40.  
  41.         return self.x+' '+self.y+ ' '+ self.z
  42.  
  43.     def show_arc(self):
  44.  
  45.         return self.x+' '+self.y
  46.  
  47.     def x_old(self):
  48.  
  49.         return self.x
  50.  
  51.     def y_old(self):
  52.  
  53.         return self.y    
  54.  
  55.     def z_old(self):
  56.  
  57.         return self.z
  58.  
  59.  
  60.  
  61. class arc_save:
  62.  
  63.     #need to save some info on arcs for creating tangent arcs
  64.  
  65.     #with center point and end point
  66.  
  67.     #probably need a line segment to start off with before doing first arc in path
  68.  
  69.     def __init__(self,cen_pt,end_pt):
  70.  
  71.         self.cent= cen_pt
  72.  
  73.         self.end = end_pt
  74.  
  75.         self.cen_x,self.cen_y = cen_pt #just in case...
  76.  
  77.         self.end_x,self.end_y = end_pt
  78.  
  79.        
  80.  
  81.     def center(self):
  82.  
  83.         return self.cent
  84.  
  85.     def end(self):
  86.  
  87.         return self.end
  88.  
  89.        
  90.  
  91. class line_save:
  92.  
  93.     #need to save some info on lines for creating tangent arcs
  94.  
  95.     #with start point and end point- will help find center of next arc
  96.  
  97.     def __init__(self,start_pt,end_pt):
  98.  
  99.         self.start= start_pt
  100.  
  101.         self.end = end_pt
  102.  
  103.        
  104.  
  105.     def start(self):
  106.  
  107.         return self.start
  108.  
  109.     def end(self):
  110.  
  111.         return self.end    
  112.  
  113.  
  114.  
  115. ################################################################################
  116.  
  117. class Parser:
  118.  
  119.  
  120.  
  121.     def __init__(self):
  122.  
  123.         self.currentx = 4.0
  124.  
  125.         self.currenty = 4.0
  126.  
  127.         self.currentz = 0.0
  128.  
  129.         self.old_position = Save(self.currentx,self.currenty,self.currentz)
  130.  
  131.         self.absolute_flag = True
  132.  
  133.  
  134.  
  135.     ############################################################################
  136.  
  137.     ##  Internals
  138.  
  139.  
  140.  
  141.     def files_open(self, name, oname=None):
  142.  
  143.         if (oname == None ):
  144.  
  145.             oname = (name+'.nc.xml')
  146.  
  147.         self.file_in = open(name, 'r')
  148.  
  149.         self.file_out = open(oname, 'w')
  150.  
  151.        
  152.  
  153.         #self.file_out.write('SET_ORIGIN_OFFSETS[0.0,0.0,0.0]\n')
  154.  
  155.         #self.file_out.write('<?xml version="1.0" ?>\n')
  156.  
  157.         #self.file_out.write('<nccode>\n')
  158.  
  159.  
  160.  
  161.     def files_close(self):
  162.  
  163.         #self.file_out.write('</nccode>\n')
  164.  
  165.  
  166.  
  167.         self.file_in.close()
  168.  
  169.         self.file_out.close()
  170.  
  171.  
  172.  
  173.     def readline(self):
  174.  
  175.         self.line = self.file_in.readline().rstrip()
  176.  
  177.         if (len(self.line)) : return True
  178.  
  179.         else : return False
  180.  
  181.  
  182.  
  183.     def write(self, s):
  184.  
  185.         self.file_out.write(s)
  186.  
  187.  
  188.  
  189.     ############################################################################
  190.  
  191.  
  192.  
  193.     def begin_ncblock(self):
  194.  
  195.         self.file_out.write('\t<ncblock>\n')
  196.  
  197.  
  198.  
  199.     def end_ncblock(self):
  200.  
  201.         self.file_out.write('\t</ncblock>\n')
  202.  
  203.  
  204.  
  205.     def add_text(self, s, col=None, cdata=False):
  206.  
  207.         s.replace('&', '&amp;')
  208.  
  209.         s.replace('"', '&quot;')
  210.  
  211.         s.replace('<', '&lt;')
  212.  
  213.         s.replace('>', '&gt;')
  214.  
  215.         if (cdata) : (cd1, cd2) = ('<![CDATA[', ']]>')
  216.  
  217.         else : (cd1, cd2) = ('', '')
  218.  
  219.         if (col != None) : self.file_out.write('\t\t<text col="'+col+'">'+cd1+s+cd2+'</text>\n')
  220.  
  221.         else : self.file_out.write('\t\t<text>'+cd1+s+cd2+'</text>\n')
  222.  
  223.  
  224.  
  225.     def set_mode(self, units=None):
  226.  
  227.         pass
  228.  
  229.         #self.file_out.write('\t\t<mode')
  230.  
  231.         #if (units != None) : self.file_out.write(' units="'+str(units)+'"')
  232.  
  233.         #self.file_out.write(' />\n')
  234.  
  235.  
  236.  
  237.     def set_tool(self, number=None):
  238.  
  239.         pass
  240.  
  241.        
  242.  
  243.     def line_style(self, line_stl="0"):
  244.  
  245.         if (line_stl== "0"):
  246.  
  247.              self.line_style_font= "/colorno 5 /linefontno 5 ]"
  248.  
  249.         else:
  250.  
  251.             self.line_style_font= "/colorno 3 ]"
  252.  
  253.  
  254.  
  255.     def begin_path(self, col=None):
  256.  
  257.         pass
  258.  
  259.         #if (col != None) : self.file_out.write(col)
  260.  
  261.         #else : self.file_out.write('\t\t<path>\n')
  262.  
  263.  
  264.  
  265.     def end_path(self):
  266.  
  267.         #self.file_out.write('\n')
  268.  
  269.         pass
  270.  
  271.  
  272.  
  273.     def add_line(self, x=None, y=None, z=None, a=None, b=None, c=None):
  274.  
  275.         if (x == None and y == None and z == None and a == None and b == None and c == None) : return
  276.  
  277.          
  278.  
  279.         self.file_out.write('Part.show(Part.makeLine(('+str(self.old_position.x_old())+' ,'+str(self.old_position.y_old())+' ,'+str(self.old_position.z_old())+' ),( ')
  280.  
  281.        
  282.  
  283.         if (x == None):
  284.  
  285.             x = self.old_position.x_old()
  286.  
  287.         if (x != None) :
  288.  
  289.             if self.absolute_flag: self.currentx = x
  290.  
  291.             else: self.currentx = self.currentx + x
  292.  
  293.             self.file_out.write(str(self.currentx)+' ,')
  294.  
  295.         if (y == None):
  296.  
  297.             y = self.old_position.y_old()
  298.  
  299.         if (y != None) :
  300.  
  301.             if self.absolute_flag: self.currenty = y
  302.  
  303.             else: self.currenty = self.currenty + y
  304.  
  305.             self.file_out.write(str(self.currenty)+' ,')
  306.  
  307.         if (z == None):
  308.  
  309.             z = self.old_position.z_old()
  310.  
  311.         if (z != None) :
  312.  
  313.             if self.absolute_flag: self.currentz = z
  314.  
  315.             else: self.currentz = self.currentz + z
  316.  
  317.             self.file_out.write(str(self.currentz))
  318.  
  319.         if (a != None) : self.file_out.write(' a="%.6f"' % a)
  320.  
  321.         if (b != None) : self.file_out.write(' b="%.6f"' % b)
  322.  
  323.         if (c != None) : self.file_out.write(' c="%.6f"' % c)
  324.  
  325.         #self.file_out.write(' ]' + self.line_style_font + '))\n')
  326.         self.file_out.write(')))\n')
  327.  
  328.         self.old_position = Save(self.currentx,self.currenty,self.currentz)
  329.  
  330.        
  331.  
  332.        
  333.  
  334.        
  335.  
  336.     def add_arc(self, x=None, y=None, z=None, i=None, j=None, k=None, r=None, d=None):
  337.  
  338.         #print self.old_pts.start, ' ' , self.old_pts.end
  339.  
  340.         if (x == None and y == None and z == None and i == None and j == None and k == None and r == None and d == None) : return
  341.  
  342.              
  343.  
  344.        
  345.  
  346.  
  347.  
  348.         if (x != None) :
  349.  
  350.             if self.absolute_flag: self.currentx = x
  351.  
  352.             else: self.currentx = self.currentx + x
  353.  
  354.             #self.file_out.write('%.6f ' % self.currentx)
  355.  
  356.         if (y != None) :
  357.  
  358.             if self.absolute_flag: self.currenty = y
  359.  
  360.             else: self.currenty = self.currenty + y
  361.  
  362.             #self.file_out.write('%.6f ' % self.currenty)
  363.  
  364.         if (z == None):
  365.  
  366.             z = self.old_position.z_old()
  367.  
  368.         if (z != None) :
  369.  
  370.             if self.absolute_flag: self.currentz = z
  371.  
  372.             else: self.currentz = self.currentz + z
  373.  
  374.             #self.file_out.write('%.6f ' % self.currentz)
  375.  
  376.            
  377.  
  378.         #come up with midpoint for 3 pt arc in graphite
  379.  
  380.        
  381.  
  382.         #if (i != None) : self.file_out.write('%.6f' % i)
  383.  
  384.         #if (j != None) : self.file_out.write('%.6f' % j)
  385.  
  386.         #if (k != None) : self.file_out.write(' k=%.6f' % k)
  387.  
  388.         #if (r != None) : self.file_out.write(' r=%.6f' % r)
  389.  
  390.         #if (d != None) : self.file_out.write(' %i,' % d) #direction of arc
  391.  
  392.         #print type(d)
  393.  
  394.         #print "d=", d
  395.  
  396.         #print "r=" ,r
  397.  
  398.         #first case- no i,j components
  399.  
  400.  
  401.  
  402.         if (i == None and j == None and r != None):
  403.  
  404.             #print 'type of self.old_position.x_old() = ', type(self.old_position.x_old())
  405.  
  406.             #print 'type of self.currentx = ', type(self.currentx)
  407.  
  408.             #find midpoint of line between start_pt and end_pt
  409.  
  410.             p1 = (self.old_position.x_old(), self.old_position.y_old())
  411.  
  412.             p2 = (self.currentx, self.currenty)
  413.  
  414.             xstart,ystart= p1;xend,yend=p2
  415.  
  416.             #find center of radius by creating circles with radius r
  417.  
  418.             #at start and end points- then determine the intersection point
  419.  
  420.             #that is on the correct side of the line going from p1 to p2
  421.  
  422.             circ_ints= g2d.circ_circ_inters(xstart,ystart, r, xend,yend, r)
  423.  
  424.             '''Return list of intersection pts of 2 circles.'''
  425.  
  426.             #print circ_ints
  427.  
  428.             cen_pt1,cen_pt2 = circ_ints
  429.  
  430.             #pt_on_RHS_p(pt, p0, p1)
  431.  
  432.             """Return True if pt is on right hand side going from p0 to p1."""
  433.  
  434.             if (d ==-1 and g2d.pt_on_RHS_p(cen_pt1,p1,p2)):
  435.  
  436.                 center = cen_pt1
  437.  
  438.                 xcen,ycen = center
  439.  
  440.                 #self.file_out.write('[/startpt ['+str(self.currentx)+' '+str(self.currenty)+' '+str(self.currentz)+' ] ')
  441.  
  442.                 #self.file_out.write('/ctrpt [ '+str(xcen)+' '+str(ycen)+' '+str(self.old_position.z_old())+' ] ')
  443.  
  444.                 #self.file_out.write( '/endpt [ '+str(self.old_position.x_old())+' '+str(self.old_position.y_old())+' '+str(self.old_position.z_old()))
  445.  
  446.                 #self.file_out.write(' ] /colorno 3]aArc aStore \n')
  447.                 #def arc_angle_format(direction,start_pt,cen_pt,end_pt,z_old):
  448.                 direction = (0,0,1)
  449.                 radius, center, start_angle, end_angle = g2d.arc_angle_format(direction,(self.currentx, self.currenty),(xcen,ycen),(self.old_position.x_old(),self.old_position.y_old()))
  450.                 self.file_out.write('Part.show(Part.makeCircle('+str(radius)+ ', Base.Vector('+str(center[0])+','+str(center[1])+','+str(self.currentz)+')'+','+' Base.Vector('+str(direction[0])+','+str(direction[1])+','+str(direction[2])+'),'+str(start_angle)+','+str(end_angle)+'))\n')  
  451.  
  452.  
  453.             else:
  454.  
  455.                 center = cen_pt2
  456.  
  457.                 xcen,ycen = center
  458.  
  459.                 #self.file_out.write('[/startpt ['+str(self.old_position.x_old())+' '+str(self.old_position.y_old())+' '+str(self.old_position.z_old())+' ] ')
  460.  
  461.                 #self.file_out.write('/ctrpt [ '+str(xcen)+' '+str(ycen)+' '+str(self.old_position.z_old())+' ] ')
  462.  
  463.                 #self.file_out.write( '/endpt [ '+str(self.currentx)+' '+str(self.currenty)+' '+str(self.currentz))
  464.  
  465.                 #self.file_out.write(' ] /colorno 3]aArc aStore \n')
  466.                 #def arc_angle_format(direction,start_pt,cen_pt,end_pt,z_old):
  467.                 #print 'Part.show(Part.makeCircle('
  468.                 direction = (0,0,1)
  469.                 radius, center, start_angle, end_angle = g2d.arc_angle_format(direction,(self.old_position.x_old(),self.old_position.y_old()),(xcen,ycen),(self.currentx, self.currenty))
  470.                 self.file_out.write('Part.show(Part.makeCircle('+str(radius)+ ', Base.Vector('+str(center[0])+','+str(center[1])+','+str(self.currentz)+')'+','+' Base.Vector('+str(direction[0])+','+str(direction[1])+','+str(direction[2])+'),'+str(start_angle)+','+str(end_angle)+'))\n')  
  471.  
  472.            
  473.  
  474.         elif (i != None and j !=None):#use i and j centers
  475.  
  476.            
  477.  
  478.             xcen = self.old_position.x_old() + i; ycen = self.old_position.y_old() + j
  479.  
  480.             if (d ==-1):
  481.  
  482.                 #self.file_out.write('[/startpt ['+str(self.currentx)+' '+str(self.currenty)+' '+str(self.currentz)+' ] ')
  483.  
  484.                 #self.file_out.write('/ctrpt [ '+str(xcen)+' '+str(ycen)+' '+str(self.old_position.z_old())+' ] ')
  485.  
  486.                 #self.file_out.write( '/endpt [ '+str(self.old_position.x_old())+' '+str(self.old_position.y_old())+' '+str(self.old_position.z_old()))
  487.  
  488.                 #self.file_out.write(' ] /colorno 3]aArc aStore \n')
  489.                 #def arc_angle_format(direction,start_pt,cen_pt,end_pt,z_old):
  490.                 #print 'Part.show(Part.makeCircle('
  491.                 direction = (0,0,1)
  492.                 radius, center, start_angle, end_angle = g2d.arc_angle_format(direction,(self.currentx, self.currenty),(xcen,ycen),(self.old_position.x_old(),self.old_position.y_old()))
  493.                 self.file_out.write('Part.show(Part.makeCircle('+str(radius)+ ', Base.Vector('+str(center[0])+','+str(center[1])+','+str(self.currentz)+')'+','+' Base.Vector('+str(direction[0])+','+str(direction[1])+','+str(direction[2])+'),'+str(start_angle)+','+str(end_angle)+'))\n')  
  494.  
  495.                
  496.  
  497.             else:
  498.  
  499.                 #self.file_out.write('[/startpt ['+str(self.old_position.x_old())+' '+str(self.old_position.y_old())+' '+str(self.old_position.z_old())+' ] ')
  500.  
  501.                 #self.file_out.write('/ctrpt [ '+str(xcen)+' '+str(ycen)+' '+str(self.old_position.z_old())+' ] ')
  502.  
  503.                 #self.file_out.write( '/endpt [ '+str(self.currentx)+' '+str(self.currenty)+' '+str(self.currentz))
  504.  
  505.                 #self.file_out.write(' ] /colorno 3]aArc aStore \n')
  506.                 #def arc_angle_format(direction,start_pt,cen_pt,end_pt,z_old):
  507.                 direction = (0,0,1)
  508.                 radius, center, start_angle, end_angle = g2d.arc_angle_format(direction,(self.old_position.x_old(),self.old_position.y_old()),(xcen,ycen),(self.currentx, self.currenty))
  509.                 self.file_out.write('Part.show(Part.makeCircle('+str(radius)+ ', Base.Vector('+str(center[0])+','+str(center[1])+','+str(self.currentz)+')'+','+' Base.Vector('+str(direction[0])+','+str(direction[1])+','+str(direction[2])+'),'+str(start_angle)+','+str(end_angle)+'))\n')  
  510.  
  511.            
  512.  
  513.         elif (x == None and i == None and j !=None):#use inferred x and i
  514.  
  515.            
  516.  
  517.             xcen = self.old_position.x_old(); ycen = self.old_position.y_old() + j
  518.  
  519.             if (d ==-1):
  520.  
  521.                 #self.file_out.write('[/startpt ['+str(self.old_position.x_old())+' '+str(self.currenty)+' '+str(self.currentz)+' ] ')
  522.  
  523.                 #self.file_out.write('/ctrpt [ '+str(xcen)+' '+str(ycen)+' '+str(self.old_position.z_old())+' ] ')
  524.  
  525.                 #self.file_out.write( '/endpt [ '+str(self.old_position.x_old())+' '+str(self.old_position.y_old())+' '+str(self.old_position.z_old()))
  526.  
  527.                 #self.file_out.write(' ] /colorno 3]aArc aStore \n')
  528.                 direction = (0,0,1)
  529.                 radius, center, start_angle, end_angle = g2d.arc_angle_format(direction,(self.old_position.x_old(),self.old_position.y_old()),(xcen,ycen),(self.currentx, self.currenty))
  530.                 self.file_out.write('Part.show(Part.makeCircle('+str(radius)+ ', Base.Vector('+str(center[0])+','+str(center[1])+','+str(self.currentz)+')'+','+' Base.Vector('+str(direction[0])+','+str(direction[1])+','+str(direction[2])+'),'+str(start_angle)+','+str(end_angle)+'))\n')  
  531.  
  532.                
  533.  
  534.             else:
  535.  
  536.                 #self.file_out.write('[/startpt ['+str(self.old_position.x_old())+' '+str(self.old_position.y_old())+' '+str(self.old_position.z_old())+' ] ')
  537.  
  538.                 #self.file_out.write('/ctrpt [ '+str(xcen)+' '+str(ycen)+' '+str(self.old_position.z_old())+' ] ')
  539.  
  540.                 #self.file_out.write( '/endpt [ '+str(self.old_position.x_old())+' '+str(self.currenty)+' '+str(self.currentz))
  541.  
  542.                 #self.file_out.write(' ] /colorno 3]aArc aStore \n')
  543.                 direction = (0,0,1)
  544.                 radius, center, start_angle, end_angle = g2d.arc_angle_format(direction,(self.old_position.x_old(),self.old_position.y_old()),(xcen,ycen),(self.currentx, self.currenty))
  545.                 self.file_out.write('Part.show(Part.makeCircle('+str(radius)+ ', Base.Vector('+str(center[0])+','+str(center[1])+','+str(self.currentz)+')'+','+' Base.Vector('+str(direction[0])+','+str(direction[1])+','+str(direction[2])+'),'+str(start_angle)+','+str(end_angle)+'))\n')  
  546.                  
  547.  
  548.         elif (i == None and j !=None):#use inferred i
  549.  
  550.            
  551.  
  552.             xcen = self.old_position.x_old(); ycen = self.old_position.y_old() + j
  553.  
  554.             if (d ==-1):
  555.  
  556.                 #self.file_out.write('[/startpt ['+str(self.currentx)+' '+str(self.currenty)+' '+str(self.currentz)+' ] ')
  557.  
  558.                 #self.file_out.write('/ctrpt [ '+str(xcen)+' '+str(ycen)+' '+str(self.old_position.z_old())+' ] ')
  559.  
  560.                 #self.file_out.write( '/endpt [ '+str(self.old_position.x_old())+' '+str(self.old_position.y_old())+' '+str(self.old_position.z_old()))
  561.  
  562.                 #self.file_out.write(' ] /colorno 3]aArc aStore \n')
  563.                 direction = (0,0,1)
  564.                 radius, center, start_angle, end_angle = g2d.arc_angle_format(direction,(self.currentx, self.currenty),(xcen,ycen),(self.old_position.x_old(),self.old_position.y_old()))
  565.                 self.file_out.write('Part.show(Part.makeCircle('+str(radius)+ ', Base.Vector('+str(center[0])+','+str(center[1])+','+str(self.currentz)+')'+','+' Base.Vector('+str(direction[0])+','+str(direction[1])+','+str(direction[2])+'),'+str(start_angle)+','+str(end_angle)+'))\n')  
  566.  
  567.                
  568.  
  569.             else:
  570.  
  571.                 #self.file_out.write('[/startpt ['+str(self.old_position.x_old())+' '+str(self.old_position.y_old())+' '+str(self.old_position.z_old())+' ] ')
  572.  
  573.                 #self.file_out.write('/ctrpt [ '+str(xcen)+' '+str(ycen)+' '+str(self.old_position.z_old())+' ] ')
  574.  
  575.                 #self.file_out.write( '/endpt [ '+str(self.currentx)+' '+str(self.currenty)+' '+str(self.currentz))
  576.  
  577.                 #self.file_out.write(' ] /colorno 3]aArc aStore \n')
  578.                 direction = (0,0,1)
  579.                 radius, center, start_angle, end_angle = g2d.arc_angle_format(direction,(self.old_position.x_old(),self.old_position.y_old()),(xcen,ycen),(self.currentx, self.currenty))
  580.                 self.file_out.write('Part.show(Part.makeCircle('+str(radius)+ ', Base.Vector('+str(center[0])+','+str(center[1])+','+str(self.currentz)+')'+','+' Base.Vector('+str(direction[0])+','+str(direction[1])+','+str(direction[2])+'),'+str(start_angle)+','+str(end_angle)+'))\n')                        
  581.  
  582.            
  583.  
  584.         elif (i != None and j ==None): #use inferred j
  585.  
  586.            
  587.  
  588.             xcen = self.old_position.x_old() + i; ycen = self.old_position.y_old()  
  589.  
  590.             if (d ==-1):
  591.  
  592.                 #self.file_out.write('[/startpt ['+str(self.currentx)+' '+str(self.currenty)+' '+str(self.currentz)+' ] ')
  593.  
  594.                 #self.file_out.write('/ctrpt [ '+str(xcen)+' '+str(ycen)+' '+str(self.old_position.z_old())+' ] ')
  595.  
  596.                 #self.file_out.write( '/endpt [ '+str(self.old_position.x_old())+' '+str(self.old_position.y_old())+' '+str(self.old_position.z_old()))
  597.  
  598.                 #self.file_out.write(' ] /colorno 3]aArc aStore \n')
  599.                 direction = (0,0,1)
  600.                 radius, center, start_angle, end_angle = g2d.arc_angle_format(direction,(self.currentx, self.currenty),(xcen,ycen),(self.old_position.x_old(),self.old_position.y_old()))
  601.                 self.file_out.write('Part.show(Part.makeCircle('+str(radius)+ ', Base.Vector('+str(center[0])+','+str(center[1])+','+str(self.currentz)+')'+','+' Base.Vector('+str(direction[0])+','+str(direction[1])+','+str(direction[2])+'),'+str(start_angle)+','+str(end_angle)+'))\n')  
  602.  
  603.                
  604.  
  605.             else:
  606.  
  607.                 #self.file_out.write('[/startpt ['+str(self.old_position.x_old())+' '+str(self.old_position.y_old())+' '+str(self.old_position.z_old())+' ] ')
  608.  
  609.                 #self.file_out.write('/ctrpt [ '+str(xcen)+' '+str(ycen)+' '+str(self.old_position.z_old())+' ] ')
  610.  
  611.                 #self.file_out.write( '/endpt [ '+str(self.currentx)+' '+str(self.currenty)+' '+str(self.currentz))
  612.  
  613.                 #self.file_out.write(' ] /colorno 3]aArc aStore \n')
  614.                 direction = (0,0,1)
  615.                 radius, center, start_angle, end_angle = g2d.arc_angle_format(direction,(self.old_position.x_old(),self.old_position.y_old()),(xcen,ycen),(self.currentx, self.currenty))
  616.                 self.file_out.write('Part.show(Part.makeCircle('+str(radius)+ ', Base.Vector('+str(center[0])+','+str(center[1])+','+str(self.currentz)+')'+','+' Base.Vector('+str(direction[0])+','+str(direction[1])+','+str(direction[2])+'),'+str(start_angle)+','+str(end_angle)+'))\n')  
  617.  
  618.                
  619.  
  620.                
  621.  
  622.                
  623.  
  624.  
  625.  
  626.         self.old_position = Save(self.currentx,self.currenty,self.currentz)
  627.  
  628.        
  629.  
  630.     def incremental(self):
  631.  
  632.         self.absolute_flag = False
  633.  
  634.         #print 'incremental!\n'
  635.  
  636.     def absolute(self):
  637.  
  638.         self.absolute_flag = True
  639.  
  640.         #print 'absolute!\n'
  641.  
  642.  
  643.  
  644.     def u_move(self):
  645.  
  646.         self.u_flag = True
  647.  
  648.  
  649.  
  650.     def w_move(self):
  651.  
  652.         self.w_flag = True
  653.  
Add Comment
Please, Sign In to add comment