import Rhino import rhinoscriptsyntax as rs from System.Drawing import Color from System import String import random a=Rhino.Input.Custom.GetOption() a.SetCommandPrompt('layer per fresata') lato=Rhino.Input.Custom.OptionInteger(0,0,999) passante=Rhino.Input.Custom.OptionToggle(False,'Non_passante','Passante') a.AddOptionInteger('lato',lato) a.AddOptionToggle('passante',passante) frese = "PATATONE","SGROSO20","FRESA16F","FRESA14F","FRESA10R","FRESA10S",\ "FRESA8F","FRESA8FN","FRESA6F","CANDELA4","CANDEL4N","CANDELA2","CANDELA3",\ "FR16LUNG","DIA20","DIA12","PLAK18SX","TONDO16" fresaIndex = 0 afrese = a.AddOptionList("fresa", frese, fresaIndex) profondita=Rhino.Input.Custom.OptionDouble(0) a.AddOptionDouble('profondita',profondita) correzione = "centro","destra","sinistra" correzioneIndex = 2 acorrezione = a.AddOptionList("correzione", correzione, correzioneIndex) prolungamento=Rhino.Input.Custom.OptionDouble(0,0,500) a.AddOptionDouble('prolungamento',prolungamento) in_e_out='nessuno','arco' in_e_outIndex=0 ain_e_out = a.AddOptionList("in_e_out", in_e_out, in_e_outIndex) angolo_in_out=Rhino.Input.Custom.OptionInteger(0,0,89) a.AddOptionInteger('angolo_in_out',angolo_in_out) raggio=Rhino.Input.Custom.OptionInteger(0,0,500) a.AddOptionInteger('raggio_in_e_out',raggio) vtr=Rhino.Input.Custom.OptionInteger(0,0,20) a.AddOptionInteger('passate',vtr) passate_orizzontali=Rhino.Input.Custom.OptionInteger(0,0,20) passo_orizzontale=Rhino.Input.Custom.OptionDouble(0,0,100) a.AddOptionInteger('passate_orizzontali',passate_orizzontali) a.AddOptionDouble('passo_orizzontale',passo_orizzontale) ovm=Rhino.Input.Custom.OptionDouble(0,-100,100) a.AddOptionDouble('sovramateriale',ovm) cuffia=Rhino.Input.Custom.OptionInteger(0,0,7) a.AddOptionInteger('cuffia',cuffia) evita_uscite_passate=Rhino.Input.Custom.OptionToggle(False , 'no' , 'si') passata_bidirezionale=Rhino.Input.Custom.OptionToggle(False , 'no' , 'si') a.AddOptionToggle('evita_uscite_passate',evita_uscite_passate) a.AddOptionToggle('passata_bidirezionale',passata_bidirezionale) while True: st=a.Get() if a.CommandResult()!=Rhino.Commands.Result.Success: print lato.CurrentValue print passante.CurrentValue print frese[fresaIndex] print correzione[correzioneIndex] print 'Urra!' break elif st==Rhino.Input.GetResult.Option: if a.OptionIndex()==afrese: fresaIndex = a.Option().CurrentListOptionIndex elif a.OptionIndex()==acorrezione: correzioneIndex = a.Option().CurrentListOptionIndex elif a.OptionIndex()==ain_e_out: in_e_outIndex = a.Option().CurrentListOptionIndex print 'ciao' continue print lato.CurrentValue , passante.CurrentValue , frese[fresaIndex] , correzione[correzioneIndex] r=random.randint(0,255) g=random.randint(0,255) b=random.randint(0,255) col=Color.FromArgb(255,r,g,b) if correzione[correzioneIndex]=='centro': crc='0' elif correzione[correzioneIndex]=='destra': crc='1' else: crc='2' if passante.CurrentValue==False: thr='0' else: thr='1' if in_e_out[in_e_outIndex]=='nessuno': tin_tou='0' else: tin_tou='1' if evita_uscite_passate.CurrentValue==False: nebs='0' else: nebs='1' if passata_bidirezionale.CurrentValue==False: bdr='0' else: bdr='1' name='TCH[ROUT](SIDE)'+repr(lato.CurrentValue)+'(DP)'+repr(profondita.CurrentValue)+\ '(TNM)$'+frese[fresaIndex]+'$(CRC)'+crc+'(DIN)'+repr(prolungamento.CurrentValue)+\ '(DOU)'+repr(prolungamento.CurrentValue)+'(OVM)'+repr(ovm.CurrentValue)+\ '(SHP)'+repr(cuffia.CurrentValue)+'(VTR)'+repr(vtr.CurrentValue)+\ '(OTR)'+repr(passate_orizzontali.CurrentValue)+'(SVR)'+repr(passo_orizzontale.CurrentValue)+\ '(THR)'+thr+'(AIN)'+repr(angolo_in_out.CurrentValue)+'(AOU)'+repr(angolo_in_out.CurrentValue)+\ '(PRP)'+repr(raggio.CurrentValue)+'(TIN)'+tin_tou+'(TOU)'+tin_tou+\ '(NEBS)'+nebs+'(BDR)'+bdr rs.AddLayer(name,col) rs.CurrentLayer(name) rs.ProjectOsnaps(True)