"""Wireframe check of CanisterStation.blend (Workbench), nothing saved: blender.exe -b ../CanisterStation.blend --python cs_preview.py Shots in previews/wire_*.png: the picture's camera, two three-quarter views, the cap.""" import bpy, os from mathutils import Vector FOLDER = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) OUTD = os.path.join(FOLDER, "previews") V = lambda x, y, z: Vector((x, y, z)) SHOTS = { "picture": None, "q_front_left": (V(-2.2, -3.4, 1.9), V(0.15, 0.0, 0.72), 50), "q_back_right": (V(3.0, 2.9, 1.8), V(0.10, 0.0, 0.75), 50), "cap": (V(1.75, -1.35, 2.05), V(0.78, 0.0, 1.30), 50), } sc = bpy.context.scene root = bpy.data.objects["CanisterStation_Root"] if root.animation_data: root.animation_data.action = None root["eject"] = 0.0 wm = bpy.data.materials.new("_wire_ink") wm.diffuse_color = (0.02, 0.02, 0.03, 1) for o in [o for o in bpy.data.objects if o.type == 'MESH' and o.name.startswith("SM_")]: t = o.copy() t.data = o.data.copy() t.name = "_w_" + o.name t.data.materials.clear() t.data.materials.append(wm) sc.collection.objects.link(t) md = t.modifiers.new("w", 'WIREFRAME') md.thickness = 0.0008 md.use_relative_offset = False md.use_even_offset = False for o in bpy.data.objects: if o.name.startswith("UCX_") or o.name.startswith("Studio_"): o.hide_render = True sc.render.engine = 'BLENDER_WORKBENCH' sh = sc.display.shading sh.light = 'STUDIO' sh.color_type = 'MATERIAL' sh.show_object_outline = False sh.show_cavity = False sc.render.film_transparent = False sc.render.image_settings.file_format = 'PNG' sc.view_settings.view_transform = 'Standard' cam = bpy.data.objects.new("_pv_cam", bpy.data.cameras.new("_pv_cam")) sc.collection.objects.link(cam) done = [] for nm, s in SHOTS.items(): if s is None: sc.camera = bpy.data.objects["CS_PictureCamera"] sc.render.resolution_x, sc.render.resolution_y = 1798, 2044 else: sc.camera = cam loc, tgt, lens = s sc.render.resolution_x, sc.render.resolution_y = 2000, 2000 cam.location = loc cam.rotation_euler = (tgt - loc).normalized().to_track_quat('-Z', 'Y').to_euler() cam.data.lens = lens cam.data.clip_start = 0.01 sc.render.filepath = os.path.join(OUTD, "wire_%s.png" % nm) bpy.ops.render.render(write_still=True) done.append(sc.render.filepath) print("PREVIEW OK", done)