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)
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)
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
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
#very simple fillet demo #the end points of the lines must be trimmed first or you #will get an error from HeeksCAD 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.add(sketch, l1) cad.add(sketch, l2) cad.fillet2d(sketch, 4, 1, 0, .1) cad.reorder(sketch)
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) cad.add(sketch, f4) cad.reorder(sketch)