fix: material override pipeline — pass --material-override CLI arg to Blender scripts

The initial implementation only overrode the material_map dict in the task,
but the Blender USD primvar path bypassed it. Now:
- Added --material-override named CLI arg parsed in _blender_args.py
- Both Mode A (factory) and Mode B (template) in _blender_scene_setup.py
  override usd_material_lookup and material_map when set
- Passed through full chain: task → step_processor → render_blender → CLI → Blender
- Tested: 175-part bearing rendered with single Steel-Bare material (1/1 materials)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-14 14:19:21 +01:00
parent 7c606953ec
commit c054236d22
5 changed files with 42 additions and 2 deletions
@@ -201,8 +201,16 @@ def render_order_line_task(self, order_line_id: str):
# Apply global material override from OutputType (e.g. x-ray mode)
if line.output_type and line.output_type.material_override:
override_mat = line.output_type.material_override
material_map = {k: override_mat for k in material_map}
emit(order_line_id, f"Material override active: all parts → {override_mat}")
# Build override map from existing material_map keys or from parsed STEP parts
override_keys = set()
if material_map:
override_keys = set(material_map.keys())
if cad_file and cad_file.parsed_objects:
for part_name in cad_file.parsed_objects.get("objects", []):
override_keys.add(part_name)
material_map = {k: override_mat for k in override_keys}
use_materials = True
emit(order_line_id, f"Material override active: {len(material_map)} parts → {override_mat}")
if template:
emit(order_line_id, f"Using render template: {template.name} (collection={template.target_collection}, material_replace={template.material_replace_enabled}, lighting_only={template.lighting_only})")
@@ -352,6 +360,7 @@ def render_order_line_task(self, order_line_id: str):
usd_path=usd_render_path,
focal_length_mm=focal_length_mm,
sensor_width_mm=sensor_width_mm,
material_override=line.output_type.material_override if line.output_type else None,
)
success = True
render_log = {
@@ -410,6 +419,7 @@ def render_order_line_task(self, order_line_id: str):
rotation_z=rotation_z,
focal_length_mm=focal_length_mm,
sensor_width_mm=sensor_width_mm,
material_override=line.output_type.material_override if line.output_type else None,
job_id=order_line_id,
order_line_id=order_line_id,
noise_threshold=noise_threshold,