exec(open(r"D:\HADAL - The Descent\models\dnr-cnc\build\lib2.py").read()) root = bpy.data.objects["DNR_CNC_Root"] C_STATIC = get_coll("CNC_Static"); C_MOVE = get_coll("CNC_Moving") for n in ("SM_DNR_ZSlide", "SM_DNR_SpindleRotor", "SM_DNR_Beacon", "SM_DNR_Table", "SM_DNR_Vise", "SM_DNR_Workpiece", "SM_DNR_ToolMagazine"): if n in bpy.data.objects: bpy.data.objects.remove(bpy.data.objects[n]) gm, bd, ti, td = MAT("Body_Gunmetal"), MAT("Body_Dark"), MAT("Titanium"), MAT("Titanium_Dark") cy, rd, gw = MAT("Glow_Cyan"), MAT("Glow_Red"), MAT("Glow_White") cg = MAT("Cast_Grey"); bz = MAT("Bezel_Black") pw = MAT("Paint_White", (0.78, 0.80, 0.82), metal=0.5, rough=0.32) ly = MAT("Label_Yellow", (0.95, 0.80, 0.05), rough=0.6) # ======================================================================= head cover (into the static body mesh) body = MB.load("SM_DNR_Body") if body.mi(cy) is None: pass hb = cube_bm((0.66, 0.90, 0.53), (0.10, -0.50, 2.565)) low = [f for f in hb.faces if f.normal.z < -0.9] bmesh.ops.delete(hb, geom=low, context='FACES_ONLY') for v in hb.verts: if v.co.z > 2.565 and v.co.y < -0.5: v.co.y += 0.22 hb.normal_update() bevel_edges(hb, [e for e in hb.edges if len(e.link_faces) == 2], 0.025, 1) body.add_bm(hb, gm) th = math.atan2(0.22, 0.53) n_ = Vector((0, -math.cos(th), math.sin(th))) P0 = Vector((0.10, -0.95, 2.30)) + 0.52 * Vector((0, 0.22, 0.53)) + n_ * 0.006 body.box((0.46, 0.012, 0.30), tuple(P0), ti, rot=(-th, 0, 0), bevel=0.004, drop=('+y',)) # side light lines on the head body.box((0.006, 0.60, 0.010), (-0.233, -0.45, 2.42), cy, drop=('+x',)) body.box((0.006, 0.60, 0.010), (0.433, -0.45, 2.42), cy, drop=('-x',)) # antenna (roof, behind the beacon) with a glowing tip body.cyl(0.012, 0.006, 0.24, (0.34, -0.22, 2.83 + 0.12), td, segs=10, caps='top') body.sphere(0.016, (0.34, -0.22, 2.83 + 0.248), cy, segs=10, rings=6) body.build(C_STATIC, parent=root) # ======================================================================= beacon (rotating light, own object) bc = MB("SM_DNR_Beacon", [td, rd]) bc.cyl(0.085, 0.075, 0.03, (0, 0, 0.015), td, segs=24, caps='top') bc.dome(0.060, (0, 0, 0.03), rd, segs=16, rings=6) bc.torus(0.072, 0.006, (0, 0, 0.034), rd, segs=24, rsegs=6) bc.build(C_MOVE, parent=root, loc=(0.10, -0.40, 2.83)) # ======================================================================= interior statics inter = MB.load("SM_DNR_Interior") inter.box((1.60, 0.70, 1.56), (0.10, 0.90, 1.40), cg, bevel=0.02, drop=('+y', '+z', '-z')) # column inter.box((0.05, 0.02, 1.45), (-0.20, 0.54, 1.40), td, bevel=0.005, drop=('+y',)) # rails inter.box((0.05, 0.02, 1.45), (0.40, 0.54, 1.40), td, bevel=0.005, drop=('+y',)) inter.box((2.40, 1.25, 0.33), (0.0, -0.125, 0.785), cg, bevel=0.02, drop=('-z',)) # bed casting inter.box((2.2, 0.05, 0.012), (0.10, -0.95, 2.174), gw, drop=('+z',)) # ceiling LED bars inter.box((2.2, 0.05, 0.012), (0.10, 0.20, 2.174), gw, drop=('+z',)) inter.cyl(0.045, 0.045, 0.235, (1.4325, -0.05, 1.70), td, rot=(0, math.radians(90), 0), segs=16, caps='none') # magazine axle inter.build(C_STATIC, parent=root) # ======================================================================= Z slide (spindle carriage) + rotor SX, SY = 0.10, -0.45 z = MB("SM_DNR_ZSlide", [pw, td, gw, ly, bz]) z.box((0.44, 1.12, 0.34), (SX, -0.04, 1.95), pw, bevel=0.02) z.cyl(0.100, 0.115, 0.12, (SX, SY, 1.72), td, segs=24, caps='bottom') z.torus(0.108, 0.007, (SX, SY, 1.664), gw, segs=32, rsegs=6) z.box((0.22, 0.006, 0.12), (SX, -0.603, 1.97), ly, drop=('+y',)) z.box((0.12, 0.05, 0.02), (SX, -0.58, 1.77), gw, drop=('+y',)) z.box((0.006, 0.70, 0.16), (SX - 0.223, -0.20, 1.95), bz, drop=('+x',)) z.box((0.006, 0.70, 0.16), (SX + 0.223, -0.20, 1.95), bz, drop=('-x',)) o_z = z.build(C_MOVE, parent=root, origin=(SX, SY, 1.95)) r = MB("SM_DNR_SpindleRotor", [td, ti]) r.cyl(0.062, 0.062, 0.04, (SX, SY, 1.64), td, segs=20, caps='bottom') r.cyl(0.028, 0.045, 0.07, (SX, SY, 1.585), td, segs=20, caps='bottom') r.cyl(0.012, 0.012, 0.15, (SX, SY, 1.475), ti, segs=12, caps='bottom') o_r = r.build(C_MOVE, parent=o_z, origin=(SX, SY, 1.66)) # ======================================================================= table (X/Y saddle + T-slotted plate) TX, TY, TZ = 0.30, -0.25, 1.20 tb = cube_bm((1.30, 0.60, 0.08), (TX, TY, TZ - 0.04)) slot_c = [-0.22, -0.11, 0.0, 0.11, 0.22] hw = 0.012 for yc in slot_c: loopcut(tb, 'y', TY + yc - hw); loopcut(tb, 'y', TY + yc + hw) tops = [f for f in tb.faces if f.normal.z > 0.9 and any(abs(f.calc_center_median().y - (TY + yc)) < hw * 0.9 for yc in slot_c)] res = bmesh.ops.extrude_face_region(tb, geom=tops) for v in [g for g in res['geom'] if isinstance(g, bmesh.types.BMVert)]: v.co.z -= 0.02 bmesh.ops.delete(tb, geom=tops, context='FACES') tb.normal_update() tbl = MB("SM_DNR_Table", [cg, td]) tbl.add_bm(tb, cg) tbl.box((1.00, 0.84, 0.17), (TX, TY, TZ - 0.165), td, bevel=0.015, drop=('+z', '-z')) o_t = tbl.build(C_MOVE, parent=root, origin=(TX, TY, TZ)) n_slots = len(tops) # vise + workpiece sitting on the table, centred under the tool vs = MB("SM_DNR_Vise", [cg, td]) vs.box((0.34, 0.20, 0.04), (SX, SY, 1.22), cg, bevel=0.008, drop=('-z',)) vs.box((0.34, 0.04, 0.08), (SX, SY + 0.07, 1.28), td, bevel=0.006, drop=('-z',)) vs.box((0.34, 0.04, 0.08), (SX, SY - 0.07, 1.28), td, bevel=0.006, drop=('-z',)) vs.cyl(0.015, 0.015, 0.15, (SX, SY - 0.165, 1.27), td, rot=(math.radians(90), 0, 0), segs=12, caps='both') vs.cyl(0.008, 0.008, 0.14, (SX, SY - 0.24, 1.27), td, rot=(0, math.radians(90), 0), segs=8, caps='both') o_v = vs.build(C_MOVE, parent=o_t, origin=(SX, SY, 1.20)) wb = cube_bm((0.16, 0.10, 0.11), (SX, SY, 1.20 + 0.04 + 0.055), bevel=0.004) topf = [f for f in wb.faces if f.normal.z > 0.9][0] pocket(wb, topf, 0.024, 0.04) wp = MB("SM_DNR_Workpiece", [ti]) wp.add_bm(wb, ti) o_w = wp.build(C_MOVE, parent=o_v, origin=(SX, SY, 1.24)) # ======================================================================= tool magazine (carousel, rotates about X) TMX, TMY, TMZ = 1.28, -0.05, 1.70 tm = MB("SM_DNR_ToolMagazine", [td, ti, cy, cg]) tm.cyl(0.38, 0.38, 0.07, (TMX, TMY, TMZ), td, rot=(0, math.radians(90), 0), segs=48, caps='both', bevel=0.008) tm.torus(0.372, 0.006, (TMX - 0.036, TMY, TMZ), cy, rot=(0, math.radians(90), 0), segs=48, rsegs=6) for k in range(12): a = 2 * math.pi * k / 12 py, pz = TMY + 0.30 * math.cos(a), TMZ + 0.30 * math.sin(a) tm.cyl(0.022, 0.032, 0.07, (TMX - 0.035 - 0.035, py, pz), td, rot=(0, math.radians(90), 0), segs=12, caps='bottom') tm.cyl(0.012, 0.012, 0.07, (TMX - 0.07 - 0.07, py, pz), ti, rot=(0, math.radians(90), 0), segs=8, caps='bottom') o_tm = tm.build(C_MOVE, parent=root, origin=(TMX, TMY, TMZ)) result = {"slots": n_slots, "audit": [audit(o) for o in (o_z, o_r, o_t, o_v, o_w, o_tm, bpy.data.objects["SM_DNR_Body"], bpy.data.objects["SM_DNR_Interior"], bpy.data.objects["SM_DNR_Beacon"])]}