def textblock(mtext, x, y, rot, color=3, mirror=0): dwg.add(dxf.line((x+50, y), (x+50, y+50), color=color)) dwg.add(dxf.line((x+100, y), (x+100, y+50), color=color)) dwg.add(dxf.line((x+150, y), (x+150, y+50), color=color)) dwg.add(dxf.line((x+50, y), (x+150, y), color=color)) dwg.add(dxf.mtext(mtext, (x+50, y), mirror=mirror, rotation=rot)) dwg.add(dxf.mtext(mtext, (x+100, y), mirror=mirror, rotation=rot, halign=dxfwrite.CENTER)) dwg.add(dxf.mtext(mtext, (x+150, y), mirror=mirror, rotation=rot, halign=dxfwrite.RIGHT)) dwg.add(dxf.line((x+50, y+25), (x+150, y+25), color=color)) dwg.add(dxf.mtext(mtext, (x+50, y+25), mirror=mirror, rotation=rot, valign=dxfwrite.MIDDLE)) dwg.add(dxf.mtext(mtext, (x+100, y+25), mirror=mirror, rotation=rot, valign=dxfwrite.MIDDLE, halign=dxfwrite.CENTER)) dwg.add(dxf.mtext(mtext, (x+150, y+25), mirror=mirror, rotation=rot, valign=dxfwrite.MIDDLE, halign=dxfwrite.RIGHT)) dwg.add(dxf.line((x+50, y+50), (x+150, y+50), color=color)) dwg.add(dxf.mtext(mtext, (x+50, y+50), mirror=mirror, valign=dxfwrite.BOTTOM, rotation=rot)) dwg.add(dxf.mtext(mtext, (x+100, y+50), mirror=mirror, valign=dxfwrite.BOTTOM, rotation=rot, halign=dxfwrite.CENTER)) dwg.add(dxf.mtext(mtext, (x+150, y+50), mirror=mirror, valign=dxfwrite.BOTTOM, rotation=rot, halign=dxfwrite.RIGHT))
def escribeEnArcoCapa(draw, texto, xCenter, yCenter, anguloIni, anguloFin, radio, color, tamFte, capa, espejo=0): # pre: espejo valor 0,1,2 # post: espejo=0 sin mirror, espejo=1 con mirror en X, espejo=2 con mirror en Y # anguloIni, anguloFin son angulos como el reloj desde las 12 print("este es el angulo inicial:", anguloIni) print("este es el angulo final:", anguloFin) anIni = traduceElAnguloRelojATrigonometria(anguloIni) anFin = traduceElAnguloRelojATrigonometria(anguloFin) print("este es el angulo calculo inicial:", anIni) print("este es el angulo calculo final:", anFin) rot = dameGradosRotacionTexto(anIni, anFin) # print ("EL ANGULO DE ROTACION DEL TEXTO ES :",rot) pX, pY = posicionaTexto(anguloIni, anguloFin, xCenter, yCenter, radio) # importante el angulo es de reloj text = dxf.mtext(texto, (pX, pY)) text.layer = capa text.color = color text.height = tamFte text.rotation = rot text.valign = dxfwrite.MIDDLE text.halign = dxfwrite.CENTER if espejo != 0: if espejo == 1: text.mirror = dxfwrite.MIRROR_X else: text.mirror = dxfwrite.MIRROR_Y draw.add(text) draw.save() print("escrito:", texto)
def escribeEnArcoCapa(draw, texto, centroX, centroY, base, anguloIni, anguloFin, color, tamFte, capa, espejo=0, rotacion=0): #pre: espejo valor 0,1,2 #post: espejo=0 sin mirror, espejo=1 con mirror en X, espejo=2 con mirror en Y text = dxf.mtext(texto, (centroX, centroY)) text.layer = capa text.color = color text.height = tamFte text.rotation = rotacion if (espejo != 0): if (espejo == 1): text.mirror = dxfwrite.MIRROR_X else: text.mirror = dxfwrite.MIRROR_Y draw.add(text) draw.save()
def escribeEnArcoCapa(draw,texto,xCenter,yCenter,anguloIni,anguloFin,radio,color,tamFte,capa,espejo=0): #pre: espejo valor 0,1,2 #post: espejo=0 sin mirror, espejo=1 con mirror en X, espejo=2 con mirror en Y # anguloIni, anguloFin son angulos como el reloj desde las 12 print ("este es el angulo inicial:",anguloIni) print ("este es el angulo final:",anguloFin) anIni = traduceElAnguloRelojATrigonometria(anguloIni) anFin = traduceElAnguloRelojATrigonometria(anguloFin) print ("este es el angulo calculo inicial:",anIni) print ("este es el angulo calculo final:",anFin) rot = dameGradosRotacionTexto(anIni,anFin) # print ("EL ANGULO DE ROTACION DEL TEXTO ES :",rot) pX,pY=posicionaTexto(anguloIni,anguloFin,xCenter,yCenter,radio)#importante el angulo es de reloj text = dxf.mtext(texto,(pX,pY)) text.layer = capa text.color = color text.height = tamFte text.rotation = rot text.valign = dxfwrite.MIDDLE text.halign = dxfwrite.CENTER if (espejo != 0): if (espejo == 1): text.mirror = dxfwrite.MIRROR_X else: text.mirror = dxfwrite.MIRROR_Y draw.add(text) draw.save() print("escrito:",texto)
def rotate_text(text, insert, parts=16, color=3): delta = 360. / parts for part in range(parts): dwg.add( dxf.mtext(text, insert, rotation=(delta * part), color=color, valign=dxfwrite.TOP))
def Ciz(self): if self.Diameter() == 1000: if self.Height() < 175: print('Hata!!') parcalar = self.Parcahesap() b60 = parcalar[1][0] b40 = parcalar[1][1] b25 = parcalar[1][2] b10 = parcalar[1][3] print( "MH={0} Kullanilacak parcalar: Temel+60x{1}+40x{2}+25x{3}+10x{4}+Konik+Kapak" .format(self.name, str(b60), str(b40), str(b25), str(b10))) dwg = dxf.drawing(self.name + ".dxf") xbase = 0 ybase = 0 self.temelciz1000(dwg, xbase, ybase) ybase += 1.2 while b60 != 0: # 60cmlik parca self.bilezikciz1000(dwg, xbase, ybase, 0.60) ybase += 0.6 b60 = b60 - 1 while b40 != 0: # 40cmlik parca self.bilezikciz1000(dwg, xbase, ybase, 0.40) ybase += 0.4 b40 = b40 - 1 while b25 != 0: # 40cmlik parca self.bilezikciz1000(dwg, xbase, ybase, 0.25) ybase += 0.25 b25 = b25 - 1 self.konikciz1000(dwg, xbase, ybase) ybase += 0.70 while b10 != 0: # 10cmlik parca self.ayarbilezikciz(dwg, xbase, ybase) ybase += 0.1 b10 = b10 - 1 self.kapakciz(dwg, xbase, ybase) # Yazi yazilar = "MH={0} \nKullanilacak parcalar:\nTemel+60x{1}+40x{2}+25x{3}+10x{4}+Konik+Kapak".format( self.name, str(b60), str(b40), str(b25), str(b10)) mtext = dxf.mtext( yazilar, (xbase - .7, ybase + .6), height=0.07, ) dwg.add(mtext) dwg.save() else: pass
def main(argv): datafile = '' outputfile = '' try: opts, args = getopt.getopt(argv, "ho:d:", ["ofile=", "dfile="]) except getopt.GetoptError: print 'barcamp-tags.py -i <inputfile> -o <outputfile>' sys.exit(2) for opt, arg in opts: if opt == '-h': print 'barcamp-tags.py -i <inputfile> -o <outputfile>' sys.exit() elif opt in ("-o", "--ofile"): outputfile = arg elif opt in ("-d", "--dfile"): datafile = arg # Open the DXF file... drawing = dxf.drawing(outputfile) row = 1 column = 1 with open(datafile, 'rb') as csvfile: data = csvfile.read().split(',') # I don't understand python. for item in data: x = row * 85.6 y = column * 53.98 print item # Append \n to long names item = item.replace(' ', '\r\n', 1) text = dxf.mtext(item, (x + offsetX, y + offsetY), height=8.5, rotation=0) text.layer = 'TEXT' text.color = 5 # Blue drawing.add(text) # Increment rows and columns (lim 6 rows) row = row + 1 if row == 7: row = 1 column = column + 1 drawing.saveas(outputfile)
def escribeEnArcoCapa(draw,texto,centroX,centroY,base,anguloIni,anguloFin,color,tamFte,capa,espejo=0,rotacion=0): #pre: espejo valor 0,1,2 #post: espejo=0 sin mirror, espejo=1 con mirror en X, espejo=2 con mirror en Y text = dxf.mtext(texto,(centroX,centroY)) text.layer = capa text.color = color text.height = tamFte text.rotation = rotacion if (espejo != 0): if (espejo == 1): text.mirror = dxfwrite.MIRROR_X else: text.mirror = dxfwrite.MIRROR_Y draw.add(text) draw.save()
def main(argv): datafile = '' outputfile = '' try: opts, args = getopt.getopt(argv,"ho:d:",["ofile=","dfile="]) except getopt.GetoptError: print 'barcamp-tags.py -i <inputfile> -o <outputfile>' sys.exit(2) for opt, arg in opts: if opt == '-h': print 'barcamp-tags.py -i <inputfile> -o <outputfile>' sys.exit() elif opt in ("-o", "--ofile"): outputfile = arg elif opt in ("-d", "--dfile"): datafile = arg # Open the DXF file... drawing = dxf.drawing(outputfile) row = 1 column = 1 with open(datafile, 'rb') as csvfile: data = csvfile.read().split(',') # I don't understand python. for item in data: x = row * 85.6 y = column * 53.98 print item # Append \n to long names item = item.replace(' ', '\r\n', 1) text = dxf.mtext(item, (x+offsetX, y+offsetY), height=8.5, rotation=0) text.layer = 'TEXT' text.color = 5 # Blue drawing.add(text) # Increment rows and columns (lim 6 rows) row = row + 1 if row == 7: row = 1 column = column + 1 drawing.saveas(outputfile)
def text(self, text, insert=None, rotation=0, color=None, **kwargs): item = dxf.mtext(text, insert=insert, rotation=rotation, color=color, **kwargs) self.add(item)
def rotate_text(text, insert, parts=16, color=3): delta = 360. / parts for part in range(parts): dwg.add(dxf.mtext(text, insert, rotation=(delta*part), color=color, valign=dxfwrite.TOP))