# Mako: orthographic Workbench renders framed exactly like the reference sheet's panels (exec'd in Blender), for # build/mk_compare.py, which lays them over the sheet. 1 render pixel per sheet pixel. TOP and SIDE at the build's scale S; # FRONT and REAR are drawn about 7 % larger on the sheet (pods 295 px there, 276 px in TOP), so they use FS. import bpy, math, os from mathutils import Vector, Matrix HERE = r"D:\HADAL - The Descent\models\tender-mako\build" exec(open(os.path.join(HERE, "mk_measure.py")).read()) OUTD = os.path.join(os.path.dirname(HERE), "previews", "compare") os.makedirs(OUTD, exist_ok=True) K = 1 FS = 0.0070 VIEWS = { # name: (sheet box x0, y0, x1, y1), metres per px, camera centre in the model, right, up, forward "top": ((30, 40, 970, 520), S, lambda bx, by: Vector(((by - TOP_CY) * S, Yi(bx), 0)), (0, 1, 0), (-1, 0, 0), (0, 0, -1)), "side": ((30, 530, 970, 1065), S, lambda bx, by: Vector((0, Yi(bx), Zi(by))), (0, 1, 0), (0, 0, 1), (-1, 0, 0)), "front": ((970, 30, 1410, 530), FS, lambda bx, by: Vector(((bx - 1185) * FS, 0, 1.03 + (150 - by) * FS)), (1, 0, 0), (0, 0, 1), (0, 1, 0)), "rear": ((960, 545, 1410, 1030), FS, lambda bx, by: Vector((-(bx - 1188) * FS, 0, 1.03 + (645 - by) * FS)), (-1, 0, 0), (0, 0, 1), (0, -1, 0)), } sc = bpy.context.scene sc.render.engine = 'BLENDER_WORKBENCH' sh = sc.display.shading sh.light = 'STUDIO'; sh.color_type = 'MATERIAL'; sh.show_object_outline = True; sh.object_outline_color = (0, 0, 0) sh.show_cavity = True sc.render.film_transparent = True sc.render.image_settings.file_format = 'PNG'; sc.render.image_settings.color_mode = 'RGBA' cam = bpy.data.objects.get("_cmp_cam") if cam is None: cam = bpy.data.objects.new("_cmp_cam", bpy.data.cameras.new("_cmp_cam")) sc.collection.objects.link(cam) cam.data.type = 'ORTHO'; cam.data.clip_start = 0.01; cam.data.clip_end = 100 prev_cam = sc.camera sc.camera = cam hide = [o for o in bpy.data.objects if o.name.startswith(("SM_Mako_Cabin", "UCX_"))] for o in hide: o.hide_render = True for name, (box, mpp, cfun, right, up, fwd) in VIEWS.items(): x0, y0, x1, y1 = box w, h = (x1 - x0), (y1 - y0) c = cfun((x0 + x1) / 2, (y0 + y1) / 2) R, U, F = Vector(right), Vector(up), Vector(fwd) m = Matrix((R, U, -F)).transposed().to_4x4() m.translation = c - F * 20 cam.matrix_world = m sc.render.resolution_x, sc.render.resolution_y = w * K, h * K sc.render.resolution_percentage = 100 cam.data.ortho_scale = max(w, h) * mpp sc.render.filepath = os.path.join(OUTD, "r_%s.png" % name) bpy.ops.render.render(write_still=True) for o in hide: o.hide_render = False sc.camera = prev_cam bpy.data.objects.remove(cam) result = sorted(os.listdir(OUTD))