component
LTC2945CMS#PBF - Wide Range I2C Power Monitor
Public Made by Adomby adom
Analog Devices (Linear Technology) LTC2945CMS#PBF: wide range I2C power monitor, 0 V to 80 V current and voltage sensing, 12-bit ADC, 24-bit power, min/max and alerts, split SDA for opto-isolation, 0 C to 70 C, MSOP-12. KiCad, Fusion and Altium libraries, 3D model and datasheet.
main
#!/usr/bin/env python3
"""Physical materials for a step2glb GLB of KiCad's MSOP-12 model (one mesh, materials told apart by the STEP's own
base colours; step2glb writes base colours only, so glTF defaults render everything as rough metal). Sets:
dark epoxy (base colour luminance < 0.1) -> "Adom.Body (epoxy)" metallic 0, roughness 0.55
pin-1 dimple (0.1 to 0.5, warm grey) -> "Adom.Body (pin-1 dimple)" metallic 0, roughness 0.75
leads (0.5 to 0.75) -> "Adom.Leads (matte tin)" metallic 1, roughness 0.35, tin colour
mark (the Adom.LaserEtch node's material) -> "Adom.LaserEtch (virtual MPN)" metallic 0, roughness 0.7
Colours are kept except the leads. usage: materials_bycolour.py in.glb [out.glb]"""
import sys
from pygltflib import GLTF2, PbrMetallicRoughness
TIN = [0.72, 0.72, 0.70, 1.0]
src = sys.argv[1]; out = sys.argv[2] if len(sys.argv) > 2 else src
g = GLTF2().load(src)
etch_mats = set()
for n in g.nodes:
if n.mesh is not None and (n.name or "").startswith("Adom.LaserEtch"):
etch_mats |= {p.material for p in g.meshes[n.mesh].primitives}
done = []
for i, m in enumerate(g.materials):
pbr = m.pbrMetallicRoughness or PbrMetallicRoughness()
c = pbr.baseColorFactor or [1, 1, 1, 1]; lum = sum(c[:3]) / 3
if i in etch_mats: m.name, metal, rough, col = "Adom.LaserEtch (virtual MPN)", 0.0, 0.7, None
elif lum < 0.1: m.name, metal, rough, col = "Adom.Body (epoxy)", 0.0, 0.55, None
elif lum < 0.5: m.name, metal, rough, col = "Adom.Body (pin-1 dimple)", 0.0, 0.75, None
elif lum < 0.75: m.name, metal, rough, col = "Adom.Leads (matte tin)", 1.0, 0.35, TIN
else: sys.exit(f"ERROR: unexpected material {i} colour {c}")
pbr.metallicFactor, pbr.roughnessFactor = metal, rough
if col: pbr.baseColorFactor = col
m.pbrMetallicRoughness = pbr; done.append(m.name)
if "Adom.Leads (matte tin)" not in done or "Adom.Body (epoxy)" not in done:
sys.exit("ERROR: body or leads material not found")
g.save(out); print("OK", out, done)