I am currently experimenting to visualise some 3D GIS data within Paraview,
I am currently able to open en visualise my obj files within ParaView GUI but I would also like to import the mtl files.
To achieve that I thought to create a state file based on the obj and mtl file using the obj-mtl-importer.py script link.
Unfortunately, I am getting multiple errors when I try to use the provided script:
- the first error is an attribute error in line 227 key.sort() full error:
Traceback (most recent call last):
File “obj-mtl-importer.py”, line 414, in
loadScene(objPath, ’s.mtl' objPath[:-4])
File “obj-mtl-importer.py”, line 384, in loadScene
mtlReader.reduceMaterialDefinitions()
File “obj-mtl-importer.py”, line 269, in reduceMaterialDefinitions
sha = materialToSHA(self.materials[name])
File “obj-mtl-importer.py”, line 227, in materialToSHA
keys.sort()
AttributeError: ‘dict_keys’ object has no attribute ‘sort’
Ass I understood, it is not possible to use the sort function anymore in python3, therefore, I changed line 227 into: sorted(keys).
This worked but then I god a second error:
- Encoding error, encoded before hashing line 230 full error:
Traceback (most recent call last):
File “obj-mtl-importer.py”, line 414, in
loadScene(objPath, ’s.mtl' objPath[:-4])
File “obj-mtl-importer.py”, line 384, in loadScene
mtlReader.reduceMaterialDefinitions()
File “obj-mtl-importer.py”, line 269, in reduceMaterialDefinitions
sha = materialToSHA(self.materials[name])
File “obj-mtl-importer.py”, line 230, in materialToSHA
m.update(key)
TypeError: Unicode-objects must be encoded before hashing
I changed line 230 and 232 into respectively: m.update(key.encode(‘utf-8’)) and m.update(token.encode(‘utf-8’))
This passed but then I have a third error
- typeError: line 65. full error:
Reducing materials from 330 to 329
Traceback (most recent call last):
File “obj-mtl-importer.py”, line 414, in
loadScene(objPath, ’s.mtl' objPath[:-4])
File “obj-mtl-importer.py”, line 386, in loadScene
objReader = OBJParser(objFilePath, ‘usemtl’)
File “obj-mtl-importer.py”, line 58, in init
self.end();
File “obj-mtl-importer.py”, line 180, in end
polydata.SetPoints(OBJParser.createPoints(pts))
File “obj-mtl-importer.py”, line 65, in createPoints
pts.SetNumberOfPoints(nbPoints);
TypeError: SetNumberOfPoints argument %Id: %V
I have no idea what this error means, and if it can be because I did something wrong while trying to fix the earlier bugs? anybody and idea what is going wrong/ what I should change?
Running windows 10 home
vtk-js-14.15.7
paraview 5.8.1
python 3.7