def upper_tabletop_2(d, dressup=True): m = Part.makeBox(d["length"], d["width"], d["upper_tabletop_t"]) m.translate(Base.Vector(-d["length"] / 2, -d["width"] / 2, 0)) m = dc.model.fillet_edges_by_length(m, 35, d["upper_tabletop_t"]) print("Upper tabletop length: ", d["length"]) print("Upper tabletop width: ", d["width"]) ccx = d["length"] - 2 * math.sqrt( ((d["cx"] + d["leg_distance_from_corner"])**2) / 2.0) ccy = d["width"] - 2 * math.sqrt( ((d["cx"] + d["leg_distance_from_corner"])**2) / 2.0) hx = ccx / 2.0 hy = ccy / 2.0 hole_points = [ Base.Vector(hx, hy, 0), Base.Vector(-hx, hy, 0), Base.Vector(-hx, -hy, 0), Base.Vector(hx, -hy, 0) ] a = 135 for p in hole_points: hole = Part.makeCylinder(d["hole_dia_tabletop"] / 2.0, d["upper_tabletop_t"], p, Base.Vector(0, 0, 1), 360) insert_1 = Part.makeBox(d["leg_t"], d["insertion_width_1"], d["insertion_length"]) insert_1 = dc.model.fillet_edges_by_length(insert_1, d["leg_edge_radii"], d["insertion_length"]) insert_1.translate(Base.Vector(-d["leg_t"] / 2, -d["cx"], 0)) insert_1.rotate(Base.Vector(0, 0, 0), Base.Vector(0, 0, 1), a) insert_1.translate(p) insert_2 = Part.makeBox(d["leg_t"], d["insertion_width_2"], d["insertion_length"]) insert_2 = dc.model.fillet_edges_by_length(insert_2, d["leg_edge_radii"], d["insertion_length"]) insert_2.translate( Base.Vector(-d["leg_t"] / 2, -d["insertion_width_3"] / 2.0, 0)) insert_2.rotate(Base.Vector(0, 0, 0), Base.Vector(0, 0, 1), a) insert_2.translate(p) m = m.cut(insert_1).cut(insert_2).cut(hole) a = a + 90 if dressup: m = dc.model.fillet_edges_longer_than(m, d["tabletop_edge_radii"], 300) m.translate(Base.Vector(0, 0, -d["upper_tabletop_t"])) return m
def lower_tabletop_2(d, dressup=True): ccx = d["length"] - 2 * math.sqrt( ((d["cx"] + d["leg_distance_from_corner"])**2) / 2.0) ccy = d["width"] - 2 * math.sqrt( ((d["cx"] + d["leg_distance_from_corner"])**2) / 2.0) length = ccx + (2 * d["leg_distance_from_corner"] + d["insertion_width_3"]) / math.sqrt(2.0) width = ccy + (2 * d["leg_distance_from_corner"] + d["insertion_width_3"]) / math.sqrt(2.0) print("Lower tabletop length: ", length) print("Lower tabletop width: ", width) m = Part.makeBox(length, width, d["lower_tabletop_t"]) m.translate(Base.Vector(-length / 2.0, -width / 2.0, 0)) m = dc.model.fillet_edges_by_length(m, 35, d["lower_tabletop_t"]) hx = ccx / 2.0 hy = ccy / 2.0 hole_points = [ Base.Vector(hx, hy, 0), Base.Vector(-hx, hy, 0), Base.Vector(-hx, -hy, 0), Base.Vector(hx, -hy, 0) ] a = 45 for p in hole_points: hole = Part.makeCylinder(d["hole_dia_tabletop"] / 2.0, d["lower_tabletop_t"], p, Base.Vector(0, 0, 1), 360) insert = Part.makeBox(d["leg_t"], d["insertion_width_3"], d["insertion_length"]) insert = dc.model.fillet_edges_by_length(insert, d["leg_edge_radii"], d["insertion_length"]) insert.translate( Base.Vector(-d["leg_t"] / 2, -d["insertion_width_3"] / 2, 0)) insert.rotate(Base.Vector(0, 0, 0), Base.Vector(0, 0, 1), -a) insert.translate(p) m = m.cut(hole).cut(insert) a = a + 90 if dressup: m = dc.model.fillet_edges_longer_than(m, d["tabletop_edge_radii"], 150) m.translate(Base.Vector(0, 0, -d["lower_tabletop_t"])) return m
def upper_tabletop_3(d, dressup=True): s = 35 x1 = d["length"] / 2.0 y1 = d["width"] / 2.0 x2 = x1 - 25 y2 = y1 - 25 p = [None] * 12 p[0] = Base.Vector(-x1, y2, 0) p[1] = Base.Vector(-x2, y1, 0) p[3] = Base.Vector(x2, y1, 0) p[4] = Base.Vector(x1, y2, 0) p[6] = Base.Vector(x1, -y2, 0) p[7] = Base.Vector(x2, -y1, 0) p[9] = Base.Vector(-x2, -y1, 0) p[10] = Base.Vector(-x1, -y2, 0) p[2] = dc.model.sagpoint(p[1], p[3], s) p[5] = dc.model.sagpoint(p[4], p[6], s) p[8] = dc.model.sagpoint(p[7], p[9], s) p[11] = dc.model.sagpoint(p[10], p[0], s) wire = [ Part.makeLine(p[0], p[1]), dc.model.makeArc(p[1:4]), Part.makeLine(p[3], p[4]), dc.model.makeArc(p[4:7]), Part.makeLine(p[6], p[7]), dc.model.makeArc(p[7:10]), Part.makeLine(p[9], p[10]), dc.model.makeArc([p[10], p[11], p[0]]) ] face = Part.Face(Part.Wire(wire)) m = face.extrude(Base.Vector(0, 0, d["upper_tabletop_t"])) m = dc.model.fillet_edges_by_length(m, 60, d["upper_tabletop_t"]) print("Upper tabletop length: ", d["length"]) print("Upper tabletop width: ", d["width"]) ccx = d["length"] - 2 * math.sqrt( ((d["cx"] + d["leg_distance_from_corner"])**2) / 2.0) ccy = d["width"] - 2 * math.sqrt( ((d["cx"] + d["leg_distance_from_corner"])**2) / 2.0) hx = ccx / 2.0 hy = ccy / 2.0 hole_points = [ Base.Vector(hx, hy, 0), Base.Vector(-hx, hy, 0), Base.Vector(-hx, -hy, 0), Base.Vector(hx, -hy, 0) ] a = 135 for p in hole_points: hole = Part.makeCylinder(d["hole_dia_tabletop"] / 2.0, d["upper_tabletop_t"] / 2.0, p, Base.Vector(0, 0, 1), 360) insert_1 = Part.makeBox(d["leg_t"], d["insertion_width_1"], d["insertion_length"]) insert_1 = dc.model.fillet_edges_by_length(insert_1, d["leg_edge_radii"], d["insertion_length"]) insert_1.translate(Base.Vector(-d["leg_t"] / 2, -d["cx"], 0)) insert_1.rotate(Base.Vector(0, 0, 0), Base.Vector(0, 0, 1), a) insert_1.translate(p) insert_2 = Part.makeBox(d["leg_t"], d["insertion_width_2"], d["insertion_length"]) insert_2 = dc.model.fillet_edges_by_length(insert_2, d["leg_edge_radii"], d["insertion_length"]) insert_2.translate( Base.Vector(-d["leg_t"] / 2, -d["insertion_width_3"] / 2.0, 0)) insert_2.rotate(Base.Vector(0, 0, 0), Base.Vector(0, 0, 1), a) insert_2.translate(p) m = m.cut(insert_1).cut(insert_2).cut(hole) a = a + 90 if dressup: m = dc.model.fillet_edges_longer_than(m, d["tabletop_edge_radii"], 300) m.translate(Base.Vector(0, 0, -d["upper_tabletop_t"])) return m
def leg(d, dressup=True): s1 = d["leg_s1"] s2 = d["leg_s2"] s3 = d["leg_s3"] s4 = d["leg_s4"] s5 = d["leg_s5"] x0 = d["insertion_width_1"] x1 = 105 x2 = d["cx"] - d["insertion_width_3"] / 2.0 x3 = x2 + d["insertion_width_2"] x4 = d["cx"] + d["insertion_width_3"] / 2.0 x5 = x2 - 20 x6 = 100 x7 = x6 - 50 y0 = d["height"] - d["upper_tabletop_t"] + d["insertion_length"] y1 = d["height"] - d["upper_tabletop_t"] - 5 y2 = y0 - 10 y3 = d["height_1"] + 100 y4 = d["height_1"] - d["insertion_length"] y5 = y4 + 15 print("Leg length: ", y0) print("Leg width: ", x3) p = [None] * 21 p[0] = Base.Vector(0, y0, 0) p[1] = Base.Vector(x0, y0, 0) p[2] = Base.Vector(x0, y1, 0) p[4] = Base.Vector(x1, y3, 0) p[6] = Base.Vector(x2, y1, 0) p[7] = Base.Vector(x2, y0, 0) p[8] = Base.Vector(x3, y0, 0) p[9] = Base.Vector(x3, y1, 0) p[11] = Base.Vector(x4, y5, 0) p[12] = Base.Vector(x4, y4, 0) p[13] = Base.Vector(x2, y4, 0) p[14] = Base.Vector(x2, y5, 0) p[15] = Base.Vector(x5, y5, 0) p[17] = Base.Vector(x6, 0, 0) p[18] = Base.Vector(x7, 0, 0) p[20] = Base.Vector(0, y2, 0) p[3] = dc.model.sagpoint(p[2], p[4], s1) p[5] = dc.model.sagpoint(p[4], p[6], s2) p[10] = dc.model.sagpoint(p[9], p[11], s3) p[16] = dc.model.sagpoint(p[15], p[17], s4) p[19] = dc.model.sagpoint(p[18], p[20], s5) wire = [ Part.makeLine(p[0], p[1]), Part.makeLine(p[1], p[2]), dc.model.makeArc(p[2:5]), dc.model.makeArc(p[4:7]), Part.makeLine(p[6], p[7]), Part.makeLine(p[7], p[8]), Part.makeLine(p[8], p[9]), dc.model.makeArc(p[9:12]), Part.makeLine(p[11], p[12]), Part.makeLine(p[12], p[13]), Part.makeLine(p[13], p[14]), Part.makeLine(p[14], p[15]), dc.model.makeArc(p[15:18]), Part.makeLine(p[17], p[18]), dc.model.makeArc(p[18:]), Part.makeLine(p[20], p[0]) ] face = Part.Face(Part.Wire(wire)) m = face.extrude(Base.Vector(0, 0, d["leg_t"])) m = dc.model.fillet_edge_xy(m, 7, p[2]) m = dc.model.fillet_edge_xy(m, 12, p[4]) m = dc.model.fillet_edge_xy(m, 7, p[6]) m = dc.model.fillet_edge_xy(m, 7, p[9]) m = dc.model.fillet_edge_xy(m, 7, p[14]) m = dc.model.fillet_edge_xy(m, 12, p[15]) m = dc.model.fillet_edge_xy(m, 30, p[20]) m.rotate(Base.Vector(0, 0, 0), Base.Vector(1, 0, 0), 90) m.translate(Base.Vector(0, d["leg_t"] / 2.0, 0)) hole = Part.makeCylinder( d["hole_dia_leg"] / 2.0, d["height"], Base.Vector(d["cx"], 0, d["height_1"] - d["insertion_length"]), Base.Vector(0, 0, 1), 360) m = m.cut(hole) if dressup: m = dc.model.fillet_edges_longer_than(m, d["leg_edge_radii"], 95) return m
def lower_tabletop_3(d, dressup=True): ccx = d["length"] - 2 * math.sqrt( ((d["cx"] + d["leg_distance_from_corner"])**2) / 2.0) ccy = d["width"] - 2 * math.sqrt( ((d["cx"] + d["leg_distance_from_corner"])**2) / 2.0) length = ccx + (2 * d["leg_distance_from_corner"] + d["insertion_width_3"]) / math.sqrt(2.0) width = ccy + (2 * d["leg_distance_from_corner"] + d["insertion_width_3"]) / math.sqrt(2.0) print("Lower tabletop length: ", length) print("Lower tabletop width: ", width) x1 = length / 2.0 y1 = width / 2.0 x2 = x1 - 25 y2 = y1 - 25 p = [None] * 12 p[0] = Base.Vector(-x1, y2, 0) p[1] = Base.Vector(-x2, y1, 0) p[3] = Base.Vector(x2, y1, 0) p[4] = Base.Vector(x1, y2, 0) p[6] = Base.Vector(x1, -y2, 0) p[7] = Base.Vector(x2, -y1, 0) p[9] = Base.Vector(-x2, -y1, 0) p[10] = Base.Vector(-x1, -y2, 0) p[2] = dc.model.sagpoint(p[1], p[3], -45) p[5] = dc.model.sagpoint(p[4], p[6], -45) p[8] = dc.model.sagpoint(p[7], p[9], -45) p[11] = dc.model.sagpoint(p[10], p[0], -45) wire = [ Part.makeLine(p[0], p[1]), dc.model.makeArc(p[1:4]), Part.makeLine(p[3], p[4]), dc.model.makeArc(p[4:7]), Part.makeLine(p[6], p[7]), dc.model.makeArc(p[7:10]), Part.makeLine(p[9], p[10]), dc.model.makeArc([p[10], p[11], p[0]]) ] face = Part.Face(Part.Wire(wire)) m = face.extrude(Base.Vector(0, 0, d["lower_tabletop_t"])) m = dc.model.fillet_edges_by_length(m, 20, d["lower_tabletop_t"]) hx = ccx / 2.0 hy = ccy / 2.0 hole_points = [ Base.Vector(hx, hy, 0), Base.Vector(-hx, hy, 0), Base.Vector(-hx, -hy, 0), Base.Vector(hx, -hy, 0) ] a = 45 for p in hole_points: hole = Part.makeCylinder(d["hole_dia_tabletop"] / 2.0, d["lower_tabletop_t"], p, Base.Vector(0, 0, 1), 360) insert = Part.makeBox(d["leg_t"], d["insertion_width_3"], d["insertion_length"]) insert = dc.model.fillet_edges_by_length(insert, d["leg_edge_radii"], d["insertion_length"]) insert.translate( Base.Vector(-d["leg_t"] / 2, -d["insertion_width_3"] / 2, 0)) insert.rotate(Base.Vector(0, 0, 0), Base.Vector(0, 0, 1), -a) insert.translate(p) m = m.cut(hole).cut(insert) a = a + 90 if dressup: m = dc.model.fillet_edges_longer_than(m, d["tabletop_edge_radii"], 150) m.translate(Base.Vector(0, 0, -d["lower_tabletop_t"])) return m
def leg(d, dressup=True): corner_protection = 14 s1 = d["leg_s1"] s2 = d["leg_s2"] s3 = d["leg_s3"] s4 = d["leg_s4"] x0 = d["cx"] + d["insertion_width"] / 2.0 + corner_protection x1 = d["cx"] - d["insertion_width"] / 2.0 + corner_protection x2 = x1 - 25 x3 = 100 x4 = 80 x5 = x3 - 55 y0 = d["height"] y2 = d["height_1"] - d["tabletop_t"] + d["insertion_length"] y1 = y2 - 12 y3 = y2 - d["insertion_length"] y5 = d["height_2"] - d["insertion_length"] y4 = y5 + d["insertion_length"] y6 = y5 + 12 y7 = y0 - 30 p = [None] * 19 p[0] = Base.Vector(0, y0, 0) p[1] = Base.Vector(x4, y0, 0) p[3] = Base.Vector(x2, y1, 0) p[4] = Base.Vector(x1, y1, 0) p[5] = Base.Vector(x1, y2, 0) p[6] = Base.Vector(x0, y2, 0) p[7] = Base.Vector(x0, y3, 0) p[9] = Base.Vector(x0, y4, 0) p[10] = Base.Vector(x0, y5, 0) p[11] = Base.Vector(x1, y5, 0) p[12] = Base.Vector(x1, y6, 0) p[13] = Base.Vector(x2, y6, 0) p[15] = Base.Vector(x3, 0, 0) p[16] = Base.Vector(x5, 0, 0) p[18] = Base.Vector(0, y7, 0) p[2] = dc.model.sagpoint(p[1], p[3], s1) p[8] = dc.model.sagpoint(p[7], p[9], s2) p[14] = dc.model.sagpoint(p[13], p[15], s3) p[17] = dc.model.sagpoint(p[16], p[18], s4) wire = [ Part.makeLine(p[0], p[1]), dc.model.makeArc(p[1:4]), Part.makeLine(p[3], p[4]), Part.makeLine(p[4], p[5]), Part.makeLine(p[5], p[6]), Part.makeLine(p[6], p[7]), dc.model.makeArc(p[7:10]), Part.makeLine(p[9], p[10]), Part.makeLine(p[10], p[11]), Part.makeLine(p[11], p[12]), Part.makeLine(p[12], p[13]), dc.model.makeArc(p[13:16]), Part.makeLine(p[15], p[16]), dc.model.makeArc([p[16], p[17], p[18]]), Part.makeLine(p[18], p[0]) ] face = Part.Face(Part.Wire(wire)) m = face.extrude(Base.Vector(0, 0, d["leg_t"])) m = dc.model.fillet_edge_xy(m, 100, p[18]) m = dc.model.fillet_edge_xy(m, 20, p[3]) m = dc.model.fillet_edge_xy(m, 8, p[4]) m = dc.model.fillet_edge_xy(m, 8, p[12]) m = dc.model.fillet_edge_xy(m, 20, p[13]) m.rotate(Base.Vector(0, 0, 0), Base.Vector(1, 0, 0), 90) m.translate(Base.Vector(-corner_protection, d["leg_t"] / 2.0, 0)) hole = Part.makeCylinder(d["hole_dia_leg"] / 2.0, d["height"], Base.Vector(d["cx"], 0, 0), Base.Vector(0, 0, 1), 360) m = m.cut(hole) corner_cutout = Part.makeBox(4.0 * d["leg_t"], 4.0 * d["leg_t"], d["glass_t"] + 2.0) corner_cutout.rotate(Base.Vector(0, 0, 0), Base.Vector(0, 0, 1), -45.0) corner_cutout.translate( Base.Vector(-2, 0, d["height"] - d["glass_t"] - 2.0)) m = m.cut(corner_cutout) if dressup: m = dc.model.fillet_edges_longer_than(m, 7, 100) return m
def tabletop(d, dressup=True): r3 = 60 # d["tabletop_r3"] s1 = d["tabletop_s1"] s2 = -100 #d["tabletop_s2"] s3 = d["tabletop_s3"] x2 = (d["length"] - 120) / 2.0 x1 = x2 - r3 y1 = (d["width"] - 120) / 2.0 y2 = y1 - r3 p = [None] * 17 p[0] = Base.Vector(-x1, y1, 0) p[2] = Base.Vector(x1, y1, 0) p[4] = Base.Vector(x2, y2, 0) p[6] = Base.Vector(x2, -y2, 0) p[8] = Base.Vector(x1, -y1, 0) p[10] = Base.Vector(-x1, -y1, 0) p[12] = Base.Vector(-x2, -y2, 0) p[14] = Base.Vector(-x2, y2, 0) p[16] = Base.Vector(-x1, y1, 0) p[1] = dc.model.sagpoint_by_r(p[0], p[2], -2500) p[3] = dc.model.sagpoint_by_r(p[2], p[4], s2) p[5] = dc.model.sagpoint(p[4], p[6], s3) p[7] = dc.model.sagpoint_by_r(p[6], p[8], s2) p[9] = dc.model.sagpoint_by_r(p[8], p[10], -2500) p[11] = dc.model.sagpoint_by_r(p[10], p[12], s2) p[13] = dc.model.sagpoint(p[12], p[14], s3) p[15] = dc.model.sagpoint_by_r(p[14], p[0], s2) face = Part.Face(Part.Wire(dc.model.create_arcs(p))) m = face.extrude(Base.Vector(0, 0, d["tabletop_t"])) m = dc.model.fillet_edges_by_length(m, 20, d["tabletop_t"]) hx = d["length"] / 2.0 - math.sqrt((d["cx"]**2) / 2.0) hy = d["width"] / 2.0 - math.sqrt((d["cx"]**2) / 2.0) print("Holes: x distance", hx * 2) print("Holes: y distance", hy * 2) print("Holes: diagonal distance", math.sqrt((hx * 2)**2 + (hy * 2)**2)) hole_points = [ Base.Vector(hx, hy, 0), Base.Vector(-hx, hy, 0), Base.Vector(-hx, -hy, 0), Base.Vector(hx, -hy, 0) ] a = 45 for p in hole_points: hole = Part.makeCylinder(d["hole_dia_tabletop"] / 2.0, d["tabletop_t"], p, Base.Vector(0, 0, 1), 360) insert = Part.makeBox(d["leg_t"], d["insertion_width"], d["insertion_length"]) insert = dc.model.fillet_edges_by_length(insert, 5, d["insertion_length"]) insert.translate( Base.Vector(-d["leg_t"] / 2.0, -d["insertion_width"] / 2.0, 0)) insert.rotate(Base.Vector(0, 0, 0), Base.Vector(0, 0, 1), -a) insert.translate(p) m = m.cut(hole).cut(insert) a = a + 90 if dressup: m = dc.model.fillet_edges_longer_than(m, 7, 300) m.translate(Base.Vector(0, 0, -d["tabletop_t"])) return m
#TORRE DE HANOI - Felipe Miranda from FreeCAD import Part from FreeCAD import Base #a base da torre base = Part.makeBox(380, 150,20) #os cilindros onde de encaixam os discos cilindro1 = Part.makeCylinder(10,150) cilindro1.translate(Base.Vector(70, 75)) cilindro2 = Part.makeCylinder(10,150) cilindro2.translate(Base.Vector(190, 75)) cilindro3 = Part.makeCylinder(10,150) cilindro3.translate(Base.Vector(310, 75)) #modelos dos discos para furá-lo modeldisco1 = Part.makeCylinder(50, 20) furo1 = Part.makeCylinder(10, 20) modeldisco2 = Part.makeCylinder(45, 20) furo2 = Part.makeCylinder(10, 20) modeldisco3 = Part.makeCylinder(40, 20) furo3 = Part.makeCylinder(10, 20) modeldisco4 = Part.makeCylinder(35, 20) furo4 = Part.makeCylinder(10, 20)