"""Quick look from the picture's own camera and an overlay on the picture, for fitting (headless, nothing saved): blender.exe -b ../CanisterStation.blend --python cs_overlay.py -- [tag] previews/fit/wb_.png Workbench, flat colours by material, the picture's framing previews/fit/overlay_.png the picture with the model's outline (silhouette and part edges) drawn over it previews/fit/blend_.png the picture and the render half and half """ import bpy, os, sys, subprocess HERE = os.path.dirname(os.path.abspath(__file__)) FOLDER = os.path.dirname(HERE) OUT = os.path.join(FOLDER, "previews", "fit") os.makedirs(OUT, exist_ok=True) argv = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [] tag = argv[0] if argv else "a" COL = {"M_CS_Black": (0.03, 0.03, 0.03), "M_CS_Green": (0.10, 0.26, 0.25), "M_CS_Grey": (0.30, 0.30, 0.31), "M_CS_Cream": (0.80, 0.76, 0.66), "M_CS_Steel": (0.62, 0.62, 0.62), "M_CS_Chrome": (0.85, 0.85, 0.85), "M_CS_Rubber": (0.01, 0.01, 0.01), "M_CS_Gap": (0.0, 0.0, 0.0), "M_CS_Screen": (0.1, 0.6, 0.6), "M_CS_PanelDark": (0.12, 0.16, 0.16), "M_CS_Glow": (0.4, 1.0, 0.9), "M_CS_Decal": (1.0, 0.85, 0.1)} sc = bpy.context.scene for m in bpy.data.materials: if m.name in COL: m.diffuse_color = COL[m.name] + (1.0,) for o in bpy.data.objects: if o.name.startswith("UCX_"): o.hide_render = True sc.camera = bpy.data.objects["CS_PictureCamera"] sc.render.engine = 'BLENDER_WORKBENCH' sh = sc.display.shading sh.light = 'STUDIO' sh.color_type = 'MATERIAL' sh.show_object_outline = False sh.show_cavity = True sh.cavity_type = 'BOTH' sc.render.film_transparent = True sc.render.resolution_x, sc.render.resolution_y = 1199, 1363 sc.render.resolution_percentage = 100 sc.render.image_settings.file_format = 'PNG' sc.render.image_settings.color_mode = 'RGBA' sc.view_settings.view_transform = 'Standard' p = os.path.join(OUT, "wb_%s.png" % tag) sc.render.filepath = p bpy.ops.render.render(write_still=True) py = r"E:\Tools\Programs\Python\python.exe" subprocess.run([py, os.path.join(HERE, "cs_overlay_img.py"), p, tag]) print("OVERLAY OK", p)