def ploter(x, y): return 'X{0}Y{1}D03*\n'.format( write_gerber_value(x, settings.format, settings.zero_suppression), write_gerber_value(y, settings.format, settings.zero_suppression), )
def to_excellon(self, settings): stmt = '' if self.x is not None: stmt += 'X%s' % write_gerber_value(self.x, settings.format, settings.zero_suppression) if self.y is not None: stmt += 'Y%s' % write_gerber_value(self.y, settings.format, settings.zero_suppression) if self.radius is not None: stmt += 'A%s' % write_gerber_value(self.radius, settings.format, settings.zero_suppression) elif self.i is not None and self.j is not None: stmt += 'I%sJ%s' % (write_gerber_value(self.i, settings.format, settings.zero_suppression), write_gerber_value(self.j, settings.format, settings.zero_suppression)) return stmt
def to_gerber(self, settings=FileSettings(), pitch=0, width=0): if pitch: return x0 = self.entity.points[0][0] y0 = self.entity.points[0][1] b = self.entity.bulge[0] gerber = 'G01*\nX{0}Y{1}D02*\nG75*'.format( write_gerber_value(x0, settings.format, settings.zero_suppression), write_gerber_value(y0, settings.format, settings.zero_suppression), ) def ptseq(): for i in range(1, len(self.entity.points)): yield i if self.entity.is_closed: yield 0 for idx in ptseq(): pt = self.entity.points[idx] x1 = pt[0] y1 = pt[1] if b == 0: gerber += '\nG01*\nX{0}Y{1}D01*'.format( write_gerber_value(x1, settings.format, settings.zero_suppression), write_gerber_value(y1, settings.format, settings.zero_suppression), ) else: ang = 4 * atan(b) xm = x0 + x1 ym = y0 + y1 t = 1 / tan(ang / 2) xc = (xm - t * (y1 - y0)) / 2 yc = (ym + t * (x1 - x0)) / 2 r = sqrt((x0 - xc) * (x0 - xc) + (y0 - yc) * (y0 - yc)) gerber += '\nG{0}*\nX{1}Y{2}I{3}J{4}D01*'.format( '03' if ang > 0 else '02', write_gerber_value(x1, settings.format, settings.zero_suppression), write_gerber_value(y1, settings.format, settings.zero_suppression), write_gerber_value(xc - x0, settings.format, settings.zero_suppression), write_gerber_value(yc - y0, settings.format, settings.zero_suppression)) x0 = x1 y0 = y1 b = self.entity.bulge[idx] return gerber
def to_gerber(self, settings=FileSettings(), pitch=0, width=0): from gerberex.dxf import DxfArcStatement if pitch == 0: x0, y0 = self.statements[0].start gerber = 'G01*\nX{0}Y{1}D02*\nG75*'.format( write_gerber_value(x0, settings.format, settings.zero_suppression), write_gerber_value(y0, settings.format, settings.zero_suppression), ) for statement in self.statements: x0, y0 = statement.start x1, y1 = statement.end if isinstance(statement, DxfArcStatement): xc, yc = statement.center gerber += '\nG{0}*\nX{1}Y{2}I{3}J{4}D01*'.format( '03' if statement.end_angle > statement.start_angle else '02', write_gerber_value(x1, settings.format, settings.zero_suppression), write_gerber_value(y1, settings.format, settings.zero_suppression), write_gerber_value(xc - x0, settings.format, settings.zero_suppression), write_gerber_value(yc - y0, settings.format, settings.zero_suppression)) else: gerber += '\nG01*\nX{0}Y{1}D01*'.format( write_gerber_value(x1, settings.format, settings.zero_suppression), write_gerber_value(y1, settings.format, settings.zero_suppression), ) else: def ploter(x, y): return 'X{0}Y{1}D03*\n'.format( write_gerber_value(x, settings.format, settings.zero_suppression), write_gerber_value(y, settings.format, settings.zero_suppression), ) gerber = self._plot_dots(pitch, width, ploter) return gerber
def to_gerber(self, settings=FileSettings(), pitch=0, width=0): if pitch: return r = self.radius x0, y0 = self.center return 'G01*\nX{0}Y{1}D02*\n' \ 'G75*\nG03*\nX{2}Y{3}I{4}J{5}D01*'.format( write_gerber_value(x0 + r, settings.format, settings.zero_suppression), write_gerber_value(y0, settings.format, settings.zero_suppression), write_gerber_value(x0 + r, settings.format, settings.zero_suppression), write_gerber_value(y0, settings.format, settings.zero_suppression), write_gerber_value(-r, settings.format, settings.zero_suppression), write_gerber_value(0, settings.format, settings.zero_suppression) )
def to_gerber(self, settings=FileSettings(), pitch=0, width=0): if pitch == 0: x0, y0 = self.start x1, y1 = self.end return 'G01*\nX{0}Y{1}D02*\nX{2}Y{3}D01*'.format( write_gerber_value(x0, settings.format, settings.zero_suppression), write_gerber_value(y0, settings.format, settings.zero_suppression), write_gerber_value(x1, settings.format, settings.zero_suppression), write_gerber_value(y1, settings.format, settings.zero_suppression)) else: gstr = "" for p in self._dots(pitch, width): gstr += 'X{0}Y{1}D03*\n'.format( write_gerber_value(p[0], settings.format, settings.zero_suppression), write_gerber_value(p[1], settings.format, settings.zero_suppression)) return gstr
def to_gerber(self, settings=FileSettings(), pitch=0, width=0): if pitch: return x0 = self.center[0] y0 = self.center[1] start_x, start_y = self.start end_x, end_y = self.end return 'G01*\nX{0}Y{1}D02*\n' \ 'G75*\nG{2}*\nX{3}Y{4}I{5}J{6}D01*'.format( write_gerber_value(start_x, settings.format, settings.zero_suppression), write_gerber_value(start_y, settings.format, settings.zero_suppression), '02' if self.start_angle > self.end_angle else '03', write_gerber_value(end_x, settings.format, settings.zero_suppression), write_gerber_value(end_y, settings.format, settings.zero_suppression), write_gerber_value(x0 - start_x, settings.format, settings.zero_suppression), write_gerber_value(y0 - start_y, settings.format, settings.zero_suppression) )