Skip to content

Commit 3067218

Browse files
committed
Don't fall over when presented with the new 'FABRIC' material. With thanks to sgebbie for providing this fix.
1 parent 6f9d51e commit 3067218

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

loadldraw/loadldraw.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,17 @@ def __readColourTable():
677677
subline = line_split[line_split.index("MATERIAL"):]
678678

679679
colour["material"] = LegoColours.__getValue(subline, "MATERIAL")
680-
hexDigits = LegoColours.__getValue(subline, "VALUE")[1:]
681-
colour["secondary_colour"] = LegoColours.hexDigitsToLinearRGBA(hexDigits, 1.0)
680+
681+
# current `FABRIC [VELVET | CANVAS | STRING | FUR]` is not yet supported.
682+
if colour["material"] == "FABRIC":
683+
debugPrint(f"Unsupported material finish: {colour['material']} for [colour: {name} code: {code}] in line: {subline}")
684+
685+
# Note, not all finishes have a secondary value
686+
finishValue = LegoColours.__getValue(subline, "VALUE")
687+
if finishValue is not None:
688+
hexDigits = finishValue[1:]
689+
colour["secondary_colour"] = LegoColours.hexDigitsToLinearRGBA(hexDigits, 1.0)
690+
682691
colour["fraction"] = LegoColours.__getValue(subline, "FRACTION")
683692
colour["vfraction"] = LegoColours.__getValue(subline, "VFRACTION")
684693
colour["size"] = LegoColours.__getValue(subline, "SIZE")

0 commit comments

Comments
 (0)