bugs in io_scene_obj addons #46165

Closed
opened 2015-09-19 13:55:40 +02:00 by Lee June · 14 comments

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
[quote]

File "E:\greensoft\3d\blender-2.74-windows64\2.74\scripts\addons\io_scene_obj\

import_obj.py", line 796, in

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

ValueError: could not convert string to float: b'1.#QNAN'
[/quote]

Then I checked the obj file and found something like following
[quote]
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
[/quote]

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
[/quote]
with
[quote]
return lambda f: float(f.upper().replace(b'.#QNAN', b'').replace(b'.#IND', b'').replace(b'.#NAN', b''))
[/quote]
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\import_obj.py 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

Thanks.

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 [quote] ``` File "E:\greensoft\3d\blender-2.74-windows64\2.74\scripts\addons\io_scene_obj\ ``` import_obj.py", line 796, in <listcomp> ``` vec[:] = [float_func(v) for v in line_split[1:]] ``` ValueError: could not convert string to float: b'1.#QNAN' [/quote] Then I checked the obj file and found something like following [quote] 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 [/quote] 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 [/quote] with [quote] return lambda f: float(f.upper().replace(b'.#QNAN', b'').replace(b'.#IND', b'').replace(b'.#NAN', b'')) [/quote] 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\import_obj.py 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 Thanks.
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @retsyo

Added subscriber: @retsyo

blender/blender#55265 was marked as duplicate of this issue

blender/blender#55265 was marked as duplicate of this issue

#54403 was marked as duplicate of this issue

#54403 was marked as duplicate of this issue
Author

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

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

Added subscriber: @mont29

Added subscriber: @mont29
Bastien Montagne self-assigned this 2015-09-19 14:30:24 +02:00

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…

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…

Added subscriber: @ideasman42

Added subscriber: @ideasman42

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 @ideasman42 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!

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 @ideasman42 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!

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'

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.

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.

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

Added subscriber: @YegorSmirnov

Added subscriber: @YegorSmirnov
Member

Added subscriber: @Siccity

Added subscriber: @Siccity
Sign in to join this conversation.
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#46165
No description provided.