Ejemplo n.º 1
0
def make_rect(originx,originy,width,length,rad,height,scale):
    #originx,originy= origin
    originx = originx*scale;originy = originy*scale
    width= width*scale;length= length*scale
    rad = rad*scale
    cad.sketch()
    sketch = cad.getlastobj()
    cad.line(originx,originy,originx+width,originy)
    l1= cad.getlastobj()
    cad.line(originx+width,originy,originx+width,originy+length)
    l2= cad.getlastobj()
    cad.line(originx+width,originy+length,originx,originy+length)
    l3= cad.getlastobj()
    cad.line(originx,originy+length,originx,originy)
    l4= cad.getlastobj()
    cad.add(sketch,l1)
    cad.add(sketch,l2)
    cad.add(sketch,l3)
    cad.add(sketch, l4)
    cad.fillet2d(sketch,originx,originy,0, rad)
    cad.fillet2d(sketch,originx+width,originy,0,rad)
    cad.fillet2d(sketch,originx+width,originy+length,0,rad)
    cad.fillet2d(sketch,originx,originy+length,0,rad)
    cad.reorder(sketch)
    cad.extrude(sketch,height*scale)
Ejemplo n.º 2
0
def make_rect(originx, originy, width, length, rad, height, scale):
    #originx,originy= origin
    originx = originx * scale
    originy = originy * scale
    width = width * scale
    length = length * scale
    rad = rad * scale
    cad.sketch()
    sketch = cad.getlastobj()
    cad.line(originx, originy, originx + width, originy)
    l1 = cad.getlastobj()
    cad.line(originx + width, originy, originx + width, originy + length)
    l2 = cad.getlastobj()
    cad.line(originx + width, originy + length, originx, originy + length)
    l3 = cad.getlastobj()
    cad.line(originx, originy + length, originx, originy)
    l4 = cad.getlastobj()
    cad.add(sketch, l1)
    cad.add(sketch, l2)
    cad.add(sketch, l3)
    cad.add(sketch, l4)
    cad.fillet2d(sketch, originx, originy, 0, rad)
    cad.fillet2d(sketch, originx + width, originy, 0, rad)
    cad.fillet2d(sketch, originx + width, originy + length, 0, rad)
    cad.fillet2d(sketch, originx, originy + length, 0, rad)
    cad.reorder(sketch)
    cad.extrude(sketch, height * scale)
Ejemplo n.º 3
0
def make_quarter_beam(type,radius):
    profile = getprofile(type)
    #cad.extrude(profile,10)
    cad.arc(-radius,0,0,.0001,math.pi/2,math.pi,0,1,0)
    cad.linearc2wire(cad.getlastobj())
    wire = cad.getlastobj()
    cad.pipe(wire,profile);
    return cad.getlastobj()
Ejemplo n.º 4
0
def make_quarter_beam(type, radius):
    profile = getprofile(type)
    #cad.extrude(profile,10)
    cad.arc(-radius, 0, 0, .0001, math.pi / 2, math.pi, 0, 1, 0)
    cad.linearc2wire(cad.getlastobj())
    wire = cad.getlastobj()
    cad.pipe(wire, profile)
    return cad.getlastobj()
Ejemplo n.º 5
0
def cut_it(obj1, obj2):
    cad.cut(obj1, obj2)
    newobj = cad.getlastobj()
    cad.remove(obj1)
    cad.changed()
    cad.remove(newobj)
    return newobj
Ejemplo n.º 6
0
def cut_it(obj1,obj2):
    cad.cut(obj1,obj2)
    newobj = cad.getlastobj()
    cad.remove(obj1)
    cad.changed()
    cad.remove(newobj)
    return newobj
Ejemplo n.º 7
0
def blank(outer_dia,inner_dia,length):
    x0,y0,z0 = 0,0,0
    rad1 = (outer_dia)*.5
    length = length
    cad.cylinder(x0,y0,z0,rad1,length)
    c1 = cad.getlastobj()

    rad2 = (inner_dia)*.5

    cad.cylinder(x0,y0,z0,rad2,length)
    c2 = cad.getlastobj()

    ring = cut_it(c1,c2)

    cad.rotate(ring,x0,y0,z0,(x0+1),y0,z0,(pi/2))
    cad.changed()
    return ring
Ejemplo n.º 8
0
def blank(outer_dia, inner_dia, length):
    x0, y0, z0 = 0, 0, 0
    rad1 = (outer_dia) * .5
    length = length
    cad.cylinder(x0, y0, z0, rad1, length)
    c1 = cad.getlastobj()

    rad2 = (inner_dia) * .5

    cad.cylinder(x0, y0, z0, rad2, length)
    c2 = cad.getlastobj()

    ring = cut_it(c1, c2)

    cad.rotate(ring, x0, y0, z0, (x0 + 1), y0, z0, (pi / 2))
    cad.changed()
    return ring
Ejemplo n.º 9
0
def make_square_beam_profile(beam_width,beam_height):
    cad.sketch()
    sketch = cad.getlastobj()

    cad.line(-beam_width/2.0,-beam_height/2.0,beam_width/2.0,-beam_height/2.0)
    cad.add(sketch,cad.getlastobj())

    cad.line(beam_width/2.0,-beam_height/2.0,beam_width/2.0,beam_height/2.0)
    cad.add(sketch,cad.getlastobj())

    cad.line(beam_width/2.0,beam_height/2.0,-beam_width/2.0,beam_height/2.0)
    cad.add(sketch,cad.getlastobj())

    cad.line(-beam_width/2.0,beam_height/2.0,-beam_width/2.0,-beam_height/2.0)
    cad.add(sketch,cad.getlastobj())
    
    cad.reorder(sketch);
    return sketch
Ejemplo n.º 10
0
    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        
Ejemplo n.º 11
0
def tooth_form(tilt,length):
    cad.sketch()
    sketch = cad.getlastobj()
    cad.line(-.0625,.1083,.0625,.1083)
    l1 = cad.getlastobj()
    cad.line(.0625,.1083,0,0)
    l2 = cad.getlastobj()
    cad.line(0,0, -.0625,.1083)
    l3 = cad.getlastobj()    
    cad.add(sketch,l1)
    cad.add(sketch,l2)
    cad.add(sketch,l3)
    cad.fillet2d(sketch,0,0,0,.002)
    cad.reorder(sketch)
    cad.extrude(sketch,length)
    form = cad.getlastobj()
    cad.rotate(form,0,0,0,1,0,0,(tilt*pi)/180)
    cad.changed()
    cad.remove(sketch)
    return form        
Ejemplo n.º 12
0
def tooth_form(tilt, length):
    cad.sketch()
    sketch = cad.getlastobj()
    cad.line(-.0625, .1083, .0625, .1083)
    l1 = cad.getlastobj()
    cad.line(.0625, .1083, 0, 0)
    l2 = cad.getlastobj()
    cad.line(0, 0, -.0625, .1083)
    l3 = cad.getlastobj()
    cad.add(sketch, l1)
    cad.add(sketch, l2)
    cad.add(sketch, l3)
    cad.fillet2d(sketch, 0, 0, 0, .002)
    cad.reorder(sketch)
    cad.extrude(sketch, length)
    form = cad.getlastobj()
    cad.rotate(form, 0, 0, 0, 1, 0, 0, (tilt * pi) / 180)
    cad.changed()
    cad.remove(sketch)
    return form
Ejemplo n.º 13
0
    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
Ejemplo n.º 14
0
def make_square_beam_profile(beam_width, beam_height):
    cad.sketch()
    sketch = cad.getlastobj()

    cad.line(-beam_width / 2.0, -beam_height / 2.0, beam_width / 2.0,
             -beam_height / 2.0)
    cad.add(sketch, cad.getlastobj())

    cad.line(beam_width / 2.0, -beam_height / 2.0, beam_width / 2.0,
             beam_height / 2.0)
    cad.add(sketch, cad.getlastobj())

    cad.line(beam_width / 2.0, beam_height / 2.0, -beam_width / 2.0,
             beam_height / 2.0)
    cad.add(sketch, cad.getlastobj())

    cad.line(-beam_width / 2.0, beam_height / 2.0, -beam_width / 2.0,
             -beam_height / 2.0)
    cad.add(sketch, cad.getlastobj())

    cad.reorder(sketch)
    return sketch
Ejemplo n.º 15
0
def polar_array(obj, tilt, num_teeth):
    circle_division = (360 / num_teeth)
    pitch_angle = (circle_division * (pi * 2)) / 360
    angle = 0
    count = 0
    while (count < num_teeth):
        t1 = tooth_form(tilt, .5)
        cad.rotate(t1, 0, 0, 0, 0, 1, 0, angle)
        cad.cut(obj, t1)
        obj2 = cad.getlastobj()
        cad.remove(obj)
        obj = obj2

        angle = angle + pitch_angle
        cad.changed()
        count = count + 1

    cad.remove(obj)
    return obj2
Ejemplo n.º 16
0
def polar_array(obj,tilt,num_teeth):
    circle_division=(360/num_teeth)
    pitch_angle = (circle_division*(pi*2))/360
    angle = 0
    count = 0
    while (count < num_teeth):
        t1 = tooth_form(tilt,.5)
        cad.rotate(t1,0,0,0,0,1,0,angle)
        cad.cut(obj,t1)
        obj2 = cad.getlastobj()
        cad.remove(obj)
        obj = obj2
        
        angle = angle + pitch_angle
        cad.changed() 
        count = count +1
    
    cad.remove(obj)         
    return obj2
Ejemplo n.º 17
0
def make_track(type,line_length,dead_zone_width,bend_radius):
    cad.group()
    group = cad.getlastobj()
    
    beam1 = make_beam(type,line_length)
    beam2 = make_beam(type,line_length)
    cad.translate(beam2,-dead_zone_width-bend_radius*2,0,0)
    beam3 = make_quarter_beam(type,bend_radius)
    beam4 = make_beam(type,dead_zone_width)
    cad.rotate(beam3,0,0,0,0,1,0,math.pi/2)
    cad.rotate(beam4,0,0,0,0,1,0,-math.pi/2)
    cad.translate(beam3,-bend_radius-dead_zone_width,0,-bend_radius)
    cad.translate(beam4,-bend_radius,0,-bend_radius)
    
    beam5 = make_quarter_beam(type,bend_radius)
    beam6 = make_beam(type,dead_zone_width)
    cad.rotate(beam5,0,0,0,0,1,0,-math.pi/2)
    cad.rotate(beam6,0,0,0,0,1,0,-math.pi/2)
    cad.translate(beam5,-bend_radius,0,line_length+bend_radius)
    cad.translate(beam6,-bend_radius,0,line_length+bend_radius)
    
    beam7 = make_quarter_beam(type,bend_radius)
    cad.rotate(beam7,0,0,0,0,1,0,math.pi)
    cad.translate(beam7,-bend_radius*2-dead_zone_width,0,line_length)
    
    beam8 = make_quarter_beam(type,bend_radius)
    
    
    cad.add(group,beam1)
    cad.add(group,beam2)
    cad.add(group,beam3)
    cad.add(group,beam4)
    cad.add(group,beam5)
    cad.add(group,beam6)
    cad.add(group,beam7)
    cad.add(group,beam8)
    return group	
Ejemplo n.º 18
0
def make_track(type, line_length, dead_zone_width, bend_radius):
    cad.group()
    group = cad.getlastobj()

    beam1 = make_beam(type, line_length)
    beam2 = make_beam(type, line_length)
    cad.translate(beam2, -dead_zone_width - bend_radius * 2, 0, 0)
    beam3 = make_quarter_beam(type, bend_radius)
    beam4 = make_beam(type, dead_zone_width)
    cad.rotate(beam3, 0, 0, 0, 0, 1, 0, math.pi / 2)
    cad.rotate(beam4, 0, 0, 0, 0, 1, 0, -math.pi / 2)
    cad.translate(beam3, -bend_radius - dead_zone_width, 0, -bend_radius)
    cad.translate(beam4, -bend_radius, 0, -bend_radius)

    beam5 = make_quarter_beam(type, bend_radius)
    beam6 = make_beam(type, dead_zone_width)
    cad.rotate(beam5, 0, 0, 0, 0, 1, 0, -math.pi / 2)
    cad.rotate(beam6, 0, 0, 0, 0, 1, 0, -math.pi / 2)
    cad.translate(beam5, -bend_radius, 0, line_length + bend_radius)
    cad.translate(beam6, -bend_radius, 0, line_length + bend_radius)

    beam7 = make_quarter_beam(type, bend_radius)
    cad.rotate(beam7, 0, 0, 0, 0, 1, 0, math.pi)
    cad.translate(beam7, -bend_radius * 2 - dead_zone_width, 0, line_length)

    beam8 = make_quarter_beam(type, bend_radius)

    cad.add(group, beam1)
    cad.add(group, beam2)
    cad.add(group, beam3)
    cad.add(group, beam4)
    cad.add(group, beam5)
    cad.add(group, beam6)
    cad.add(group, beam7)
    cad.add(group, beam8)
    return group
Ejemplo n.º 19
0
def make_beam_profile(beam_width, beam_height, beam_thickness):
    cad.sketch()
    sketch = cad.getlastobj()

    cad.line(-beam_width / 2.0, -beam_height / 2.0, beam_width / 2.0,
             -beam_height / 2.0)
    cad.add(sketch, cad.getlastobj())
    cad.line(-beam_width / 2.0, -beam_height / 2.0, -beam_width / 2.0,
             -beam_height / 2.0 + beam_thickness)
    cad.add(sketch, cad.getlastobj())
    cad.line(-beam_width / 2.0, -beam_height / 2.0 + beam_thickness,
             -beam_thickness / 2.0, -beam_height / 2.0 + beam_thickness)
    cad.add(sketch, cad.getlastobj())
    cad.line(beam_thickness / 2.0, -beam_height / 2.0 + beam_thickness,
             beam_width / 2.0, -beam_height / 2.0 + beam_thickness)
    cad.add(sketch, cad.getlastobj())
    cad.line(beam_width / 2.0, -beam_height / 2.0 + beam_thickness,
             beam_width / 2.0, -beam_height / 2.0)
    cad.add(sketch, cad.getlastobj())

    cad.line(beam_thickness / 2.0, -beam_height / 2.0 + beam_thickness,
             beam_thickness / 2.0, beam_height / 2.0 - beam_thickness)
    cad.add(sketch, cad.getlastobj())
    cad.line(-beam_thickness / 2.0, -beam_height / 2.0 + beam_thickness,
             -beam_thickness / 2.0, beam_height / 2.0 - beam_thickness)
    cad.add(sketch, cad.getlastobj())

    cad.line(-beam_width / 2.0, beam_height / 2.0, beam_width / 2.0,
             beam_height / 2.0)
    cad.add(sketch, cad.getlastobj())
    cad.line(-beam_width / 2.0, beam_height / 2.0, -beam_width / 2.0,
             beam_height / 2.0 - beam_thickness)
    cad.add(sketch, cad.getlastobj())
    cad.line(-beam_width / 2.0, beam_height / 2.0 - beam_thickness,
             -beam_thickness / 2.0, beam_height / 2.0 - beam_thickness)
    cad.add(sketch, cad.getlastobj())
    cad.line(beam_thickness / 2.0, beam_height / 2.0 - beam_thickness,
             beam_width / 2.0, beam_height / 2.0 - beam_thickness)
    cad.add(sketch, cad.getlastobj())
    cad.line(beam_width / 2.0, beam_height / 2.0 - beam_thickness,
             beam_width / 2.0, beam_height / 2.0)
    cad.add(sketch, cad.getlastobj())

    cad.reorder(sketch)
    return sketch
Ejemplo n.º 20
0
def make_beam(type, length):
    profile = getprofile(type)
    cad.extrude(profile, length)
    return cad.getlastobj()
Ejemplo n.º 21
0
def make_beam(type,length):
    profile = getprofile(type)
    cad.extrude(profile,length)
    return cad.getlastobj()
Ejemplo n.º 22
0
def make_beam_profile(beam_width,beam_height,beam_thickness):
    cad.sketch()
    sketch = cad.getlastobj()

    cad.line(-beam_width/2.0,-beam_height/2.0,beam_width/2.0,-beam_height/2.0)
    cad.add(sketch,cad.getlastobj())
    cad.line(-beam_width/2.0,-beam_height/2.0,-beam_width/2.0,-beam_height/2.0+beam_thickness)
    cad.add(sketch,cad.getlastobj())
    cad.line(-beam_width/2.0,-beam_height/2.0+beam_thickness,-beam_thickness/2.0,-beam_height/2.0+beam_thickness)
    cad.add(sketch,cad.getlastobj())
    cad.line(beam_thickness/2.0,-beam_height/2.0+beam_thickness,beam_width/2.0,-beam_height/2.0+beam_thickness)
    cad.add(sketch,cad.getlastobj())
    cad.line(beam_width/2.0,-beam_height/2.0+beam_thickness,beam_width/2.0,-beam_height/2.0)
    cad.add(sketch,cad.getlastobj())
    
    cad.line(beam_thickness/2.0,-beam_height/2.0+beam_thickness,beam_thickness/2.0,beam_height/2.0-beam_thickness)
    cad.add(sketch,cad.getlastobj())
    cad.line(-beam_thickness/2.0,-beam_height/2.0+beam_thickness,-beam_thickness/2.0,beam_height/2.0-beam_thickness)
    cad.add(sketch,cad.getlastobj())
    
    cad.line(-beam_width/2.0,beam_height/2.0,beam_width/2.0,beam_height/2.0)
    cad.add(sketch,cad.getlastobj())
    cad.line(-beam_width/2.0,beam_height/2.0,-beam_width/2.0,beam_height/2.0-beam_thickness)
    cad.add(sketch,cad.getlastobj())
    cad.line(-beam_width/2.0,beam_height/2.0-beam_thickness,-beam_thickness/2.0,beam_height/2.0-beam_thickness)
    cad.add(sketch,cad.getlastobj())
    cad.line(beam_thickness/2.0,beam_height/2.0-beam_thickness,beam_width/2.0,beam_height/2.0-beam_thickness)
    cad.add(sketch,cad.getlastobj())
    cad.line(beam_width/2.0,beam_height/2.0-beam_thickness,beam_width/2.0,beam_height/2.0)
    cad.add(sketch,cad.getlastobj())
    
    cad.reorder(sketch);
    return sketch
Ejemplo n.º 23
0
# this example shows how to create fillets between two lines

import HeeksPython as cad
cad.sketch()
sketch = cad.getlastobj()
cad.line(0,1,4,1)
l1= cad.getlastobj()
cad.line(4,1,4,2)
l2= cad.getlastobj()

cad.line(4,2,0,2)
l3= cad.getlastobj()

cad.line(0,2,0,1)
l4= cad.getlastobj()

cad.add(sketch,l1)
cad.add(sketch,l2)
cad.add(sketch,l3)
cad.add(sketch, l4)
cad.fillet2d(sketch,4,1,0,.1)
f1= cad.getlastobj()
cad.fillet2d(sketch,4,2,0,.1)
f2= cad.getlastobj()
cad.fillet2d(sketch,0,2,0,.1)
f3= cad.getlastobj()
cad.fillet2d(sketch,0,1,0, .1)
f4= cad.getlastobj()
cad.add(sketch,f1)
cad.add(sketch,f2)
cad.add(sketch,f3)
Ejemplo n.º 24
0
# this example shows how to create fillets between two lines

import HeeksPython as cad
cad.sketch()
sketch = cad.getlastobj()
cad.line(0,1,4,1)
l1= cad.getlastobj()
cad.line(4,1,4,2)
l2= cad.getlastobj()
cad.line(4,2,0,2)
l3= cad.getlastobj()
cad.line(0,2,0,1)
l4= cad.getlastobj()
cad.add(sketch,l1)
cad.add(sketch,l2)
cad.add(sketch,l3)
cad.add(sketch, l4)
cad.fillet2d(sketch,0,1,0, .1)
cad.fillet2d(sketch,4,1,0,.1)
cad.fillet2d(sketch,4,2,0,.1)
cad.fillet2d(sketch,0,2,0,.1)
cad.reorder(sketch)
Ejemplo n.º 25
0
import HeeksPython as cad


def cut_it(obj1, obj2):
    cad.cut(obj1, obj2)
    newobj = cad.getlastobj()
    cad.remove(obj1)
    cad.changed()
    cad.remove(newobj)
    return newobj


cad.cuboid(0, 0, 0, 1, 1, 1)
c1 = cad.getlastobj()
cad.cylinder(0, 0, 0, .5, 1)
c2 = cad.getlastobj()
n1 = cut_it(c1, c2)

cad.cylinder(1, 0, 0, .5, 1)
c3 = cad.getlastobj()
n2 = cut_it(n1, c3)

cad.cylinder(1, 1, 0, .5, 1)
c4 = cad.getlastobj()
n3 = cut_it(n2, c4)

cad.cylinder(0, 1, 0, .5, 1)
c5 = cad.getlastobj()
n4 = cut_it(n3, c5)

cad.ve()
Ejemplo n.º 26
0
    l1 = cad.getlastobj()
    cad.line(originx + width, originy, originx + width, originy + length)
    l2 = cad.getlastobj()
    cad.line(originx + width, originy + length, originx, originy + length)
    l3 = cad.getlastobj()
    cad.line(originx, originy + length, originx, originy)
    l4 = cad.getlastobj()
    cad.add(sketch, l1)
    cad.add(sketch, l2)
    cad.add(sketch, l3)
    cad.add(sketch, l4)
    cad.fillet2d(sketch, originx, originy, 0, rad)
    cad.fillet2d(sketch, originx + width, originy, 0, rad)
    cad.fillet2d(sketch, originx + width, originy + length, 0, rad)
    cad.fillet2d(sketch, originx, originy + length, 0, rad)
    cad.reorder(sketch)
    cad.extrude(sketch, height * scale)


cad.setcolor(100, 200, 55)
make_rect(originx, originy, width, length, corner_rad, height, scale)
b1 = cad.getlastobj()
box2_width = width * .6
box2_length = length * .6
make_rect(((originx + width * .5) - box2_width * .5),
          ((originy + length * .5) - box2_length * .5), box2_width,
          box2_length, corner_rad * .75, height, scale)
b2 = cad.getlastobj()
cad.cut(b1, b2)
cad.view_extents()
Ejemplo n.º 27
0
import HeeksPython as cad
def cut_it(obj1,obj2):
    cad.cut(obj1,obj2)
    newobj = cad.getlastobj()
    cad.remove(obj1)
    cad.changed()
    cad.remove(newobj)
    return newobj


cad.cuboid(0,0,0,1,1,1)
c1 = cad.getlastobj()
cad.cylinder(0,0,0,.5,1)
c2 = cad.getlastobj()
n1 = cut_it(c1,c2)

cad.cylinder(1,0,0,.5,1)
c3 = cad.getlastobj()
n2 = cut_it(n1,c3)

cad.cylinder(1,1,0,.5,1)
c4 = cad.getlastobj()
n3 = cut_it(n2,c4)

cad.cylinder(0,1,0,.5,1)
c5 = cad.getlastobj()
n4 = cut_it(n3,c5)

cad.ve()

Ejemplo n.º 28
0
#this little script shows how to use the 'revolve' function
#used for revolving sketches around X axis to form a solid
#like a turned part on a lathe

import HeeksPython as cad
cad.sketch()
sketch = cad.getlastobj()
cad.line(0, 1, 4, 1)
l1 = cad.getlastobj()
cad.line(4, 1, 4, 2)
l2 = cad.getlastobj()
cad.line(4, 2, 0, 2)
l3 = cad.getlastobj()
cad.line(0, 2, 0, 1)
l4 = cad.getlastobj()
cad.add(sketch, l1)
cad.add(sketch, l2)
cad.add(sketch, l3)
cad.add(sketch, l4)
cad.reorder(sketch)
cad.revolve(sketch, 360)
Ejemplo n.º 29
0
    cad.sketch()
    sketch = cad.getlastobj()
    cad.line(originx,originy,originx+width,originy)
    l1= cad.getlastobj()
    cad.line(originx+width,originy,originx+width,originy+length)
    l2= cad.getlastobj()
    cad.line(originx+width,originy+length,originx,originy+length)
    l3= cad.getlastobj()
    cad.line(originx,originy+length,originx,originy)
    l4= cad.getlastobj()
    cad.add(sketch,l1)
    cad.add(sketch,l2)
    cad.add(sketch,l3)
    cad.add(sketch, l4)
    cad.fillet2d(sketch,originx,originy,0, rad)
    cad.fillet2d(sketch,originx+width,originy,0,rad)
    cad.fillet2d(sketch,originx+width,originy+length,0,rad)
    cad.fillet2d(sketch,originx,originy+length,0,rad)
    cad.reorder(sketch)
    cad.extrude(sketch,height*scale)

cad.setcolor(100, 200, 55)
make_rect(originx,originy,width,length,corner_rad,height,scale)
b1= cad.getlastobj()
box2_width=width*.6
box2_length=length*.6
make_rect(((originx+width*.5)-box2_width*.5),((originy+length*.5)-box2_length*.5),box2_width,box2_length,corner_rad*.75,height,scale)
b2 = cad.getlastobj()
cad.cut(b1,b2)
cad.view_extents()