"""Wireframe check of RobotCell.blend (Workbench), nothing saved: blender.exe -b ../RobotCell.blend --python rc_preview.py Shots in previews/wire_*.png: the picture's camera, two three-quarter views, the robot.""" 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(-5.6, -6.4, 2.6), V(0.0, 0.0, 1.15), 40), "q_back_right": (V(5.8, 5.2, 3.0), V(0.0, 0.0, 1.1), 40), "robot": (V(0.6, -2.6, 1.6), V(-0.85, -0.05, 1.15), 35), } sc = bpy.context.scene root = bpy.data.objects["RobotCell_Root"] if root.animation_data: root.animation_data.action = None for k in ("door_left", "door_right", "side_door", "turntable", "estop"): root[k] = 0.0 sc.frame_set(1) 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_") or o.name.startswith("SK_"))]: 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) o.hide_render = True md = t.modifiers.new("w", 'WIREFRAME') md.thickness = 0.0020 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["RC_PictureCamera"] sc.render.resolution_x, sc.render.resolution_y = 2400, 1920 else: sc.camera = cam loc, tgt, lens = s sc.render.resolution_x, sc.render.resolution_y = 2400, 1800 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)