I have a huge amount of .wrl files. They mostly contain a single mesh. I want to write a small python script that loads each of these files, then reduces the contained meshes and saves it to a new file (ideally again a .wrl, but not necessary)

My script so far

import bpy
import os

for i in os.listdir("C:/PathToFiles"):
    if i.endswith("n.wrl"):
        fullPath = "C:/PathToFiles/" + i




The saving part is missing for now. When first trying this I got the error message "blendata not defined" in line 2223 of import_x3d.py. I corrected this by replacing all occurences of blendata with bpydata.

Now it crashes with error in line 2044 of import_x3d.py with

ValueError: matrix * vector: len(matrix.col) and len(vector) must be the same

Since I have no real insight into the script or the .wrl file format I am kinda lost. Any suggestions?


I'm not entirely sure that it does the exact right thing but...

I edited the lines 2044 and 2045 to following lines in the import_x3d.py script in order to fix the error message I got. Basic idea is to just prolong the uv vector to 4 components and then copy the first to back to the target.

tmp = texmtx * luv.uv.to_4d()
luv.uv = tmp.xy

The scenes seem to be loaded, but I have not checked the UV coordinates in detail since for now I don't care that much about them. I may later.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.