sttng / LDD

Code and scripts for LDD and Renderman
MIT License
18 stars 3 forks source link

IndexError: list index out of range #8

Closed Sarah-C closed 1 month ago

Sarah-C commented 4 months ago

Hiyah! Great converter! It does the textures too, cool!

There's an issue with some of the items, it bombs out with an index error for the material, and I wondered if you have time to look at it?


- DB Version: 2670 Database OK. Scene "TV (WIP)" Brickversion: 604.1 Traceback (most recent call last):-----------------] 50.0% (87079) FLAT TILE 2X4 File "C:\tmp\pyldd2obj.py", line 719, in main() File "C:\tmp\pyldd2obj.py", line 713, in main converter.Export(filename=obj_filename) File "C:\tmp\pyldd2obj.py", line 635, in Export lddmat = self.allMaterials.getMaterialbyId(pa.materials[part]) IndexError: list index out of range


I had a go at fixing it, but I don't know what the data structures are doing, so I just default to part[0]:

```
        for part in geo.Parts:

                if (len(pa.materials) >= part - 1):
                    lddmat = self.allMaterials.getMaterialbyId(pa.materials[0])
                else:
                    lddmat = self.allMaterials.getMaterialbyId(pa.materials[part])

                matname = lddmat.name

                deco = '0'
                if hasattr(pa, 'decoration') and len(geo.Parts[part].textures) > 0:
                    if decoCount <= len(pa.decoration):
                        deco = pa.decoration[decoCount]
                    decoCount += 1
sttng commented 1 month ago

Stuff in this repo is just outdated and old. Here is a newer version (albeit also not maintained for a long time): https://github.com/sttng/LegoToR