LDD icon indicating copy to clipboard operation
LDD copied to clipboard

IndexError: list index out of range

Open Sarah-C opened this issue 9 months ago • 0 comments

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
	

Sarah-C avatar May 09 '24 11:05 Sarah-C