refactor: rebrand project to HartOMat
This commit is contained in:
@@ -89,7 +89,7 @@ def import_usd_file(usd_path: str) -> tuple[list, dict]:
|
||||
"""Import USD stage into current Blender scene — delegates to import_usd module.
|
||||
|
||||
Returns (parts, material_lookup) where material_lookup maps
|
||||
blender_object_name → canonical SCHAEFFLER material name (from USD primvars).
|
||||
blender_object_name → canonical HARTOMAT material name (from USD primvars).
|
||||
"""
|
||||
from import_usd import import_usd_file as _impl
|
||||
result = _impl(usd_path)
|
||||
|
||||
@@ -5,7 +5,7 @@ import os
|
||||
import re as _re
|
||||
import time as _time
|
||||
|
||||
FAILED_MATERIAL_NAME = "SCHAEFFLER_059999_FailedMaterial"
|
||||
FAILED_MATERIAL_NAME = "HARTOMAT_059999_FailedMaterial"
|
||||
|
||||
|
||||
def _find_material_with_nodes(base_name: str):
|
||||
@@ -100,7 +100,7 @@ def _batch_append_materials(mat_lib_path: str, names: set[str]) -> dict:
|
||||
def assign_failed_material(part_obj) -> None:
|
||||
"""Assign the standard fallback material (magenta) when no library material matches.
|
||||
|
||||
Reuses SCHAEFFLER_059999_FailedMaterial if already loaded; otherwise
|
||||
Reuses HARTOMAT_059999_FailedMaterial if already loaded; otherwise
|
||||
creates a simple magenta Principled BSDF node tree.
|
||||
"""
|
||||
import bpy # type: ignore[import]
|
||||
@@ -157,7 +157,7 @@ def apply_material_library_direct(
|
||||
"""Assign materials from library using a direct object_name → material_name mapping.
|
||||
|
||||
This bypasses all name-matching heuristics — the mapping comes from USD
|
||||
customData (schaeffler:canonicalMaterialName) read via pxr after Blender import.
|
||||
customData (hartomat:canonicalMaterialName) read via pxr after Blender import.
|
||||
Parts not present in material_lookup receive FAILED_MATERIAL_NAME.
|
||||
|
||||
material_lookup: {blender_object_name: canonical_material_name}
|
||||
|
||||
@@ -83,7 +83,7 @@ def _setup_mode_b(args, lap_fn: Callable[[str], None]) -> None:
|
||||
_unassigned = [p for p in parts if not p.data.materials or
|
||||
(len(p.data.materials) == 1 and
|
||||
p.data.materials[0] and
|
||||
p.data.materials[0].name == "SCHAEFFLER_059999_FailedMaterial")]
|
||||
p.data.materials[0].name == "HARTOMAT_059999_FailedMaterial")]
|
||||
if _unassigned:
|
||||
print(f"[blender_render] {len(_unassigned)} parts without USD primvar — "
|
||||
f"falling back to name-matching", flush=True)
|
||||
@@ -162,7 +162,7 @@ def _setup_mode_a(args) -> None:
|
||||
_unassigned = [p for p in parts if not p.data.materials or
|
||||
(len(p.data.materials) == 1 and
|
||||
p.data.materials[0] and
|
||||
p.data.materials[0].name == "SCHAEFFLER_059999_FailedMaterial")]
|
||||
p.data.materials[0].name == "HARTOMAT_059999_FailedMaterial")]
|
||||
if _unassigned:
|
||||
apply_material_library(
|
||||
_unassigned, args.material_library_path,
|
||||
|
||||
@@ -19,7 +19,7 @@ def apply_asset_library_materials(blend_path: str, material_map: dict, link: boo
|
||||
Args:
|
||||
blend_path: Absolute path to the .blend library file.
|
||||
material_map: Mapping of current slot material name -> library material name.
|
||||
E.g. {"Steel--Stahl": "SCHAEFFLER_010101_Steel-Bare"}
|
||||
E.g. {"Steel--Stahl": "HARTOMAT_010101_Steel-Bare"}
|
||||
link: If True (default), link materials (external reference, good for rendering).
|
||||
If False, append materials (local copy — required for GLB/GLTF export so
|
||||
that the exporter can traverse Principled BSDF node trees for PBR values).
|
||||
|
||||
@@ -577,7 +577,7 @@ def main():
|
||||
if material_map:
|
||||
_unassigned = [p for p in parts if not p.data.materials or
|
||||
(len(p.data.materials) == 1 and p.data.materials[0] and
|
||||
p.data.materials[0].name == "SCHAEFFLER_059999_FailedMaterial")]
|
||||
p.data.materials[0].name == "HARTOMAT_059999_FailedMaterial")]
|
||||
if _unassigned:
|
||||
print(f"[cinematic_render] {len(_unassigned)} parts without USD primvar -- "
|
||||
f"falling back to name-matching", flush=True)
|
||||
@@ -654,7 +654,7 @@ def main():
|
||||
if material_map:
|
||||
_unassigned = [p for p in parts if not p.data.materials or
|
||||
(len(p.data.materials) == 1 and p.data.materials[0] and
|
||||
p.data.materials[0].name == "SCHAEFFLER_059999_FailedMaterial")]
|
||||
p.data.materials[0].name == "HARTOMAT_059999_FailedMaterial")]
|
||||
if _unassigned:
|
||||
_apply_material_library_shared(
|
||||
_unassigned, material_library_path,
|
||||
|
||||
@@ -754,8 +754,8 @@ def main() -> None:
|
||||
try:
|
||||
extras_payload: dict = {}
|
||||
if sharp_pairs:
|
||||
extras_payload["schaeffler_sharp_edge_pairs"] = sharp_pairs
|
||||
extras_payload["schaeffler_sharp_threshold_deg"] = args.sharp_threshold
|
||||
extras_payload["hartomat_sharp_edge_pairs"] = sharp_pairs
|
||||
extras_payload["hartomat_sharp_threshold_deg"] = args.sharp_threshold
|
||||
if part_key_map:
|
||||
extras_payload["partKeyMap"] = part_key_map
|
||||
if extras_payload:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""STEP → USD exporter for Schaeffler Automat.
|
||||
"""STEP → USD exporter for HartOMat.
|
||||
|
||||
Reads a STEP file via OCP/XCAF (preserving part names + embedded colors),
|
||||
tessellates with BRepMesh, builds a USD stage mirroring the full XCAF
|
||||
@@ -18,7 +18,7 @@ Usage:
|
||||
[--color_map '{"Ring": "#4C9BE8"}'] \\
|
||||
[--sharp_threshold 20.0] \\
|
||||
[--cad_file_id uuid] \\
|
||||
[--material_map '{"part_name": "SCHAEFFLER_010101_Steel-Bare", ...}']
|
||||
[--material_map '{"part_name": "HARTOMAT_010101_Steel-Bare", ...}']
|
||||
|
||||
Exit 0 on success, exit 1 on failure.
|
||||
Prints MANIFEST_JSON: {...} to stdout before exit.
|
||||
@@ -418,8 +418,8 @@ def _author_xcaf_to_usd(
|
||||
_occ_trsf_to_usd_matrix(local_loc.Transformation()))
|
||||
|
||||
prim = xform.GetPrim()
|
||||
prim.SetCustomDataByKey("schaeffler:sourceName", source_name)
|
||||
prim.SetCustomDataByKey("schaeffler:sourceAssemblyPath", xcaf_path)
|
||||
prim.SetCustomDataByKey("hartomat:sourceName", source_name)
|
||||
prim.SetCustomDataByKey("hartomat:sourceAssemblyPath", xcaf_path)
|
||||
|
||||
print(f" {' ' * depth}[asm] {source_name} → {xform_path}"
|
||||
f"{' (transform)' if has_local_trsf else ''}")
|
||||
@@ -484,16 +484,16 @@ def _author_xcaf_to_usd(
|
||||
_occ_trsf_to_usd_matrix(local_loc.Transformation()))
|
||||
|
||||
prim = xform.GetPrim()
|
||||
prim.SetCustomDataByKey("schaeffler:partKey", part_key)
|
||||
prim.SetCustomDataByKey("schaeffler:sourceName", source_name)
|
||||
prim.SetCustomDataByKey("schaeffler:sourceAssemblyPath", xcaf_path)
|
||||
prim.SetCustomDataByKey("schaeffler:sourceColor", hex_color)
|
||||
prim.SetCustomDataByKey("schaeffler:tessellation:linearDeflectionMm",
|
||||
prim.SetCustomDataByKey("hartomat:partKey", part_key)
|
||||
prim.SetCustomDataByKey("hartomat:sourceName", source_name)
|
||||
prim.SetCustomDataByKey("hartomat:sourceAssemblyPath", xcaf_path)
|
||||
prim.SetCustomDataByKey("hartomat:sourceColor", hex_color)
|
||||
prim.SetCustomDataByKey("hartomat:tessellation:linearDeflectionMm",
|
||||
args.linear_deflection)
|
||||
prim.SetCustomDataByKey("schaeffler:tessellation:angularDeflectionRad",
|
||||
prim.SetCustomDataByKey("hartomat:tessellation:angularDeflectionRad",
|
||||
args.angular_deflection)
|
||||
if args.cad_file_id:
|
||||
prim.SetCustomDataByKey("schaeffler:cadFileId", args.cad_file_id)
|
||||
prim.SetCustomDataByKey("hartomat:cadFileId", args.cad_file_id)
|
||||
|
||||
# ── UsdGeomMesh ────────────────────────────────────────────
|
||||
mesh = UsdGeom.Mesh.Define(stage, mesh_path)
|
||||
@@ -525,13 +525,13 @@ def _author_xcaf_to_usd(
|
||||
|
||||
# ── Material metadata on mesh prim (customData) ───────────
|
||||
mesh_prim = mesh.GetPrim()
|
||||
mesh_prim.SetCustomDataByKey("schaeffler:partKey", part_key)
|
||||
mesh_prim.SetCustomDataByKey("schaeffler:sourceName", source_name)
|
||||
mesh_prim.SetCustomDataByKey("hartomat:partKey", part_key)
|
||||
mesh_prim.SetCustomDataByKey("hartomat:sourceName", source_name)
|
||||
|
||||
canonical_mat = _lookup_material(source_name, part_key, mat_map_lower)
|
||||
if canonical_mat:
|
||||
mesh_prim.SetCustomDataByKey(
|
||||
"schaeffler:canonicalMaterialName", canonical_mat)
|
||||
"hartomat:canonicalMaterialName", canonical_mat)
|
||||
|
||||
primvars_api = UsdGeom.PrimvarsAPI(mesh)
|
||||
|
||||
@@ -542,7 +542,7 @@ def _author_xcaf_to_usd(
|
||||
idx_pairs = _world_to_index_pairs(vertices, sharp_pairs)
|
||||
if idx_pairs:
|
||||
pv = primvars_api.CreatePrimvar(
|
||||
"schaeffler:sharpEdgeVertexPairs",
|
||||
"hartomat:sharpEdgeVertexPairs",
|
||||
Sdf.ValueTypeNames.Int2Array,
|
||||
UsdGeom.Tokens.constant,
|
||||
)
|
||||
@@ -556,7 +556,7 @@ def _author_xcaf_to_usd(
|
||||
seam_idx_pairs = _world_to_index_pairs(vertices, seam_pairs)
|
||||
if seam_idx_pairs:
|
||||
pv_seam = primvars_api.CreatePrimvar(
|
||||
"schaeffler:seamEdgeVertexPairs",
|
||||
"hartomat:seamEdgeVertexPairs",
|
||||
Sdf.ValueTypeNames.Int2Array,
|
||||
UsdGeom.Tokens.constant,
|
||||
)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Runs inside Blender's Python environment (bpy available).
|
||||
Imports a USD stage and restores seam + sharp edges from
|
||||
schaeffler:*EdgeVertexPairs primvars. Blender's built-in USD importer does
|
||||
hartomat:*EdgeVertexPairs primvars. Blender's built-in USD importer does
|
||||
NOT map arbitrary custom primvars (constant Int2Array) to mesh attributes,
|
||||
so we read them directly via the pxr module and apply via bmesh.
|
||||
|
||||
@@ -22,7 +22,7 @@ def import_usd_file(usd_path: str) -> list | tuple:
|
||||
Returns a tuple of (parts, material_lookup) where:
|
||||
- parts: list of imported mesh objects, centred at world origin
|
||||
- material_lookup: dict mapping blender_object_name → canonical_material_name
|
||||
(populated from schaeffler:canonicalMaterialName customData, empty dict if absent)
|
||||
(populated from hartomat:canonicalMaterialName customData, empty dict if absent)
|
||||
|
||||
USD stage is mm Y-up with metersPerUnit=0.001 — Blender scales to metres.
|
||||
"""
|
||||
@@ -49,20 +49,20 @@ def import_usd_file(usd_path: str) -> list | tuple:
|
||||
for prim in stage.Traverse():
|
||||
if prim.GetTypeName() != "Mesh":
|
||||
continue
|
||||
part_key = prim.GetCustomDataByKey("schaeffler:partKey") or ""
|
||||
mat_name = prim.GetCustomDataByKey("schaeffler:canonicalMaterialName") or ""
|
||||
part_key = prim.GetCustomDataByKey("hartomat:partKey") or ""
|
||||
mat_name = prim.GetCustomDataByKey("hartomat:canonicalMaterialName") or ""
|
||||
if not part_key or not mat_name:
|
||||
parent = prim.GetParent()
|
||||
if parent:
|
||||
part_key = part_key or (parent.GetCustomDataByKey("schaeffler:partKey") or "")
|
||||
mat_name = mat_name or (parent.GetCustomDataByKey("schaeffler:canonicalMaterialName") or "")
|
||||
part_key = part_key or (parent.GetCustomDataByKey("hartomat:partKey") or "")
|
||||
mat_name = mat_name or (parent.GetCustomDataByKey("hartomat:canonicalMaterialName") or "")
|
||||
if part_key and mat_name:
|
||||
material_lookup[part_key] = mat_name
|
||||
|
||||
# Read seam/sharp primvars from USD mesh prim
|
||||
pvs_api = UsdGeom.PrimvarsAPI(prim)
|
||||
sharp_pv = pvs_api.GetPrimvar("schaeffler:sharpEdgeVertexPairs")
|
||||
seam_pv = pvs_api.GetPrimvar("schaeffler:seamEdgeVertexPairs")
|
||||
sharp_pv = pvs_api.GetPrimvar("hartomat:sharpEdgeVertexPairs")
|
||||
seam_pv = pvs_api.GetPrimvar("hartomat:seamEdgeVertexPairs")
|
||||
sharp_list = []
|
||||
seam_list = []
|
||||
if sharp_pv and sharp_pv.HasValue():
|
||||
@@ -83,7 +83,7 @@ def import_usd_file(usd_path: str) -> list | tuple:
|
||||
print(f"[import_usd] pxr material lookup: {len(material_lookup)}/{len(parts)} parts",
|
||||
flush=True)
|
||||
else:
|
||||
print("[import_usd] no schaeffler:canonicalMaterialName metadata found (legacy USD)",
|
||||
print("[import_usd] no hartomat:canonicalMaterialName metadata found (legacy USD)",
|
||||
flush=True)
|
||||
|
||||
if edge_data:
|
||||
|
||||
@@ -345,7 +345,7 @@ def main():
|
||||
part_colors_json = args[6] if len(args) > 6 else "{}"
|
||||
transparent_bg = args[7] == "1" if len(args) > 7 else False
|
||||
|
||||
# Template + material library args (passed by schaeffler-still.js)
|
||||
# Template + material library args (passed by hartomat-still.js)
|
||||
template_path = args[8] if len(args) > 8 and args[8] else ""
|
||||
target_collection = args[9] if len(args) > 9 else "Product"
|
||||
material_library_path = args[10] if len(args) > 10 and args[10] else ""
|
||||
|
||||
@@ -317,7 +317,7 @@ def main():
|
||||
samples = int(args[7])
|
||||
part_colors_json = args[8] if len(args) > 8 else "{}"
|
||||
|
||||
# Template + material library args (passed by schaeffler-turntable.js)
|
||||
# Template + material library args (passed by hartomat-turntable.js)
|
||||
template_path = args[9] if len(args) > 9 and args[9] else ""
|
||||
target_collection = args[10] if len(args) > 10 else "Product"
|
||||
material_library_path = args[11] if len(args) > 11 and args[11] else ""
|
||||
@@ -468,7 +468,7 @@ def main():
|
||||
if material_map:
|
||||
_unassigned = [p for p in parts if not p.data.materials or
|
||||
(len(p.data.materials) == 1 and p.data.materials[0] and
|
||||
p.data.materials[0].name == "SCHAEFFLER_059999_FailedMaterial")]
|
||||
p.data.materials[0].name == "HARTOMAT_059999_FailedMaterial")]
|
||||
if _unassigned:
|
||||
print(f"[turntable_render] {len(_unassigned)} parts without USD primvar — "
|
||||
f"falling back to name-matching", flush=True)
|
||||
@@ -559,7 +559,7 @@ def main():
|
||||
if material_map:
|
||||
_unassigned = [p for p in parts if not p.data.materials or
|
||||
(len(p.data.materials) == 1 and p.data.materials[0] and
|
||||
p.data.materials[0].name == "SCHAEFFLER_059999_FailedMaterial")]
|
||||
p.data.materials[0].name == "HARTOMAT_059999_FailedMaterial")]
|
||||
if _unassigned:
|
||||
_apply_material_library_shared(
|
||||
_unassigned, material_library_path,
|
||||
|
||||
Reference in New Issue
Block a user