def GenCode(self, event): # wxGlade: MyFrame.<event_handler> cad.sketch() sketch = cad.getlastobj() x_center=float(self.x_center_entry.GetValue()) y_center=float(self.y_center_entry.GetValue()) z_center=float(self.z_center_entry.GetValue()) no_of_holes=float(self.no_of_holes_entry.GetValue()) bolt_circle_diameter=float(self.bolt_circle_diameter_entry.GetValue()) start_angle=float(self.start_angle_entry.GetValue()) scale=float(self.Scale_entry.GetValue()) count = 0 anglecount=1 circle_division_angle=(360/no_of_holes) calc_angle=start_angle while (count < no_of_holes): x1=math.cos(math.radians(calc_angle))*(bolt_circle_diameter/2) y1=math.sin(math.radians(calc_angle))*(bolt_circle_diameter/2) x=(x1+x_center)*scale y=(y1+y_center)*scale z=(z_center)*scale cad.point(x,y,z) cad.add(sketch,cad.getlastobj()) data=str('X%.4f Y%.4f Z%.4f '% (x, y, z)+'\n') print data anglecount=anglecount+1 calc_angle=calc_angle + circle_division_angle count=count+1 cad.reorder(sketch); return sketch
def GenCode(self, event): # wxGlade: MyFrame.<event_handler> cad.sketch() sketch = cad.getlastobj() x_center = float(self.x_center_entry.GetValue()) y_center = float(self.y_center_entry.GetValue()) z_center = float(self.z_center_entry.GetValue()) no_of_holes = float(self.no_of_holes_entry.GetValue()) bolt_circle_diameter = float( self.bolt_circle_diameter_entry.GetValue()) start_angle = float(self.start_angle_entry.GetValue()) scale = float(self.Scale_entry.GetValue()) count = 0 anglecount = 1 circle_division_angle = (360 / no_of_holes) calc_angle = start_angle while (count < no_of_holes): x1 = math.cos( math.radians(calc_angle)) * (bolt_circle_diameter / 2) y1 = math.sin( math.radians(calc_angle)) * (bolt_circle_diameter / 2) x = (x1 + x_center) * scale y = (y1 + y_center) * scale z = (z_center) * scale cad.point(x, y, z) cad.add(sketch, cad.getlastobj()) data = str('X%.4f Y%.4f Z%.4f ' % (x, y, z) + '\n') print data anglecount = anglecount + 1 calc_angle = calc_angle + circle_division_angle count = count + 1 cad.reorder(sketch) return sketch