Page MenuHome

bugs in io_scene_obj addons
Closed, ArchivedPublic


Broken for 2.74, 2.75 and 2.76

When I try to import an obj file, which is said to be exported by zmodeler, I get this

File "E:\greensoft\3d\blender-2.74-windows64\2.74\scripts\addons\io_scene_obj\", line 796, in <listcomp>

vec[:] = [float_func(v) for v in line_split[1:]]

ValueError: could not convert string to float: b'1.#QNAN'

Then I checked the obj file and found something like following
vn 1.#QNAN -1.#IND -1.#IND
vn 0.970273 0.199445 -0.137085
vn 1.#QNAN -1.#IND -1.#IND
vn 0.894082 0.387011 -0.225478
vn 1.#QNAN -1.#IND -1.#IND

So I changed 2 lines in "def get_float_func(filepath):". Because '1.' is placed before 'QNAN', I think the change can be done by simple replace
[quote please remember this line appears twice]
return float
return lambda f: float(f.upper().replace(b'.#QNAN', b'').replace(b'.#IND', b'').replace(b'.#NAN', b''))
But this should be checked wether it is a univerisal way to deal with all 'QNAN' and 'IND'.

And I when I checked scripts\addons\io_scene_obj\ in blender 2.74/2.75/2.76, I found that all of them share the same 'get_float_func' function. So the fix will be possible for 2.74/2.75/2.76


Event Timeline

Lee June (retsyo) raised the priority of this task from to 90.
Lee June (retsyo) updated the task description. (Show Details)
Lee June (retsyo) added a project: BF Blender.
Lee June (retsyo) edited a custom field.

how about ignore the normal if the value is invalid, and do a 'calculate the normal' after importation?

Yeah… never saw such thing in an .OBJ file, and pretty sure this is not covered by the format definition at all. In fact, this heavily looks like a bug in zmodeler exporter to me. Anyway, will add some more safety checks here…

Bastien Montagne (mont29) lowered the priority of this task from 90 to Normal.Sep 19 2015, 2:30 PM

OK, have a patch which basically uses try/except around float 'parsing' func… Makes parsing of the file about 4-5% slower though (total import about 2-3% slower).

Would like to summon @Campbell Barton (campbellbarton) here though, I really do not feel like adding that extra stuff for what is quite obviously a broken file - we cannot support all stupidity of external app world in Blender, and think we can expect a reasonable level of format-correctness for our importers?

Note that those 1.#QNAN, -1.#IND etc. are windows-version of nan and inf, that is, invalid of infinite numbers. Think those should never ever be exported in an .obj!

Bastien Montagne (mont29) changed the task status from Unknown Status to Archived.Sep 20 2015, 11:17 AM

So, talked with Campbell on IRC, we agree that we shall not try to support broken .obj (if we start there, we'll never end), bug is in the app that is exporting such files, not in Blender anyway.

note that you could report a bug to zmodeler instead. such files shouldn't be written.