file_o = """//============================================== //INSERIMENTO DATI nomeecognome="%s"; numerocarta= "%s"; datascadenza= "%s"; //============================================== difference(){ $fn=100; minkowski() { cube([85,53,1]); cylinder(r=2,h=.5); }; translate([1, 43, .5]) { linear_extrude(h=2){ text(nomeecognome, font = "BankGothicBold", size=5.5); } }; translate([85/18, 43/3, .5]) { linear_extrude(h=2){ text(numerocarta, font = "BankGothicBold", size=5); } }; translate([85/18, 43/14, .5]) { linear_extrude(h=2){ text("Valid Thru", font = "BankGothicBold", size=4); } }; translate([85/2, 43/14, .5]) { linear_extrude(h=2){ text(datascadenza, font = "BankGothicBold", size=4); } }; translate([165,4,.5]) linear_extrude(h=2){ import("C:/Users/federico/Desktop/logo bnl.dxf"); } } """ ### ^ testo del file. Puoi impostarlo "hardcoded" of che venga letto da un file. Tre virgolette prendono le stringhe multitesto i = raw_input("Inserisci tre parametri separati da virgola: ") #Prendi 3 valori separati da virgola params = [p.strip() for p in i.split(',')] #Params = Genera array [rimuovi spazi a dx e sx dei valori di i file_f = file_o%tuple(params[:3]) #General File Finale. Sostituisci %s in file_o con i primi 3 valori di params print(file_f) #Stampa a schermo ##### DECOMMENTA DA QUA IN POI PER CREARE IL FILE ############## #f = open("./gen_file.osc", "w+") #f.write(file_f)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question