def make_pgm(): strprg = {} data = json.loads(request.vars.jsonstring) print json.dumps(data, sort_keys=True, indent=4) print '****** PLASMA CUT *******' id_pgm = 1234 prgr = Plasma.PlasmaCutPlan(id_pgm) centerx = float(data['shape_data']['misure2']) / 2 + float( data['data_form']['sheet_margin_left']) centery = float(data['shape_data']['misure3']) / 2 + float( data['data_form']['sheet_margin_bottom']) cutid = 1 # percorso taglio dei fori # if 'holes' in data['shape_data'].keys(): for holes in data['shape_data']['holes']: if holes['intfo'] <> '': modulo = float(holes['intfo']) / 2 else: modulo = 0 print 'modulo:', modulo if holes['num'] <> '': numfori = int(holes['num']) else: numfori = 1 print 'numfori:', numfori if holes['par'] <> '': angpar = int(holes['par']) else: angpar = 0 print 'angpar:', angpar angpasso = 360 / numfori for i in range(0, numfori): cutid = cutid + 1 cx = centerx + modulo * math.cos( math.radians(angpar + angpasso * i)) cy = centery + modulo * math.sin( math.radians(angpar + angpasso * i)) prgr.cutseq.append( Plasma.CutRound(cutid, float(holes['dia']), cx + float(holes['dia']) / 2, cy, 'ccw')) print 'foro' + str(i) print 'x:', cx, ' y:', cy # percorso taglio della piastra # if data['shape_data']['shape'] == 1: on_set = 8 out_set = 6 xstart = float(data['shape_data']['misure2']) + float( data['data_form']['sheet_margin_left']) ystart = float(data['data_form']['sheet_margin_bottom']) print xstart print ystart prgr.cutseq.append( Plasma.CutRect(1, float(data['shape_data']['misure2']), float(data['shape_data']['misure3']), xstart, ystart, 'cw')) elif data['shape_data']['shape'] == 2: on_set = 8 out_set = 6 print 'allora!' diam = data['shape_data']['misure2'] print 'diametro:', diam xstart = centerx + diam * 0.707 ystart = centery - diam * 0.707 prgr.cutseq.append(Plasma.CutRound(1, diam, xstart, ystart, 'cw')) #prgr.cutseq.append(Plasma.CutRect(1,100,300,250,250,'ccw')) #prgr.cutseq.append(Plasma.CutRound(2, 500, 426.75, 73.25,'cw')) strprg = prgr.run() return json.dumps(strprg)