Import .obj with more than one unnamed object fails. #67673

Closed
opened 2019-07-25 16:21:42 +02:00 by Jeff Barbier · 11 comments

System Information
Operating system: Darwin-17.7.0-x86_64-i386-64bit 64 Bits
Graphics card: NVIDIA GeForce GTX 1080 Ti OpenGL Engine NVIDIA Corporation 4.1 NVIDIA-10.33.0 387.10.10.10.40.122

Blender Version
Broken: version: 2.80 (sub 74), branch: master, commit date: 2019-07-18 14:52, hash: 38d4483c6a
Worked: (2.79b)

Short description of error
Import .obj with more than one unnamed object fails.

Exact steps for others to reproduce the error
Based on the default startup
File > Import > Wavefront (.obj) attached files

One unnamed object is ok
single_unnamed.obj

Two named objects are ok
two_named.obj

Two unnamed fails :
two_unnamed.obj

Traceback (most recent call last):

File "Blender.app/Contents/Resources/2.80/scripts/addons/io_scene_obj/__init__.py", line 145, in execute
  return import_obj.load(context, **keywords)
File "Blender.app/Contents/Resources/2.80/scripts/addons/io_scene_obj/import_obj.py", line 1128, in load
  context_object_key = unique_name(objects_names, line_value(line_split))
File "Blender.app/Contents/Resources/2.80/scripts/addons/io_scene_obj/import_obj.py", line 898, in unique_name
  name = b"%s.%03d" % (name_orig, i)

TypeError: %b requires a bytes-like object, or an object that implements bytes, not 'NoneType'

location: :-1

**System Information** Operating system: Darwin-17.7.0-x86_64-i386-64bit 64 Bits Graphics card: NVIDIA GeForce GTX 1080 Ti OpenGL Engine NVIDIA Corporation 4.1 NVIDIA-10.33.0 387.10.10.10.40.122 **Blender Version** Broken: version: 2.80 (sub 74), branch: master, commit date: 2019-07-18 14:52, hash: `38d4483c6a` Worked: (2.79b) **Short description of error** Import .obj with more than one unnamed object fails. **Exact steps for others to reproduce the error** Based on the default startup File > Import > Wavefront (.obj) attached files One unnamed object is ok [single_unnamed.obj](https://archive.blender.org/developer/F7628269/single_unnamed.obj) Two named objects are ok [two_named.obj](https://archive.blender.org/developer/F7628277/two_named.obj) Two unnamed fails : [two_unnamed.obj](https://archive.blender.org/developer/F7628278/two_unnamed.obj) Traceback (most recent call last): ``` File "Blender.app/Contents/Resources/2.80/scripts/addons/io_scene_obj/__init__.py", line 145, in execute return import_obj.load(context, **keywords) File "Blender.app/Contents/Resources/2.80/scripts/addons/io_scene_obj/import_obj.py", line 1128, in load context_object_key = unique_name(objects_names, line_value(line_split)) File "Blender.app/Contents/Resources/2.80/scripts/addons/io_scene_obj/import_obj.py", line 898, in unique_name name = b"%s.%03d" % (name_orig, i) ``` TypeError: %b requires a bytes-like object, or an object that implements __bytes__, not 'NoneType' location: <unknown location>:-1
Author

Added subscriber: @ph-1

Added subscriber: @ph-1

Added subscriber: @rjg

Added subscriber: @rjg

The function unique_name fails to generate unique names when the provided name_orig is None. I'm not sure if empty names are allowed in the format, it's not mentioned in the spec. This could be fixed by generating a random name.

What software produced these .obj files?

The function `unique_name` fails to generate unique names when the provided `name_orig` is `None`. I'm not sure if empty names are allowed in the format, it's not mentioned in the spec. This could be fixed by generating a random name. What software produced these .obj files?

Added subscriber: @mont29

Added subscriber: @mont29

@mont29 Your opinion on this?

@mont29 Your opinion on this?
Author

I produced those 3 .obj files by hand with some basic cube example to illustrate the problem.
I noticed this while working on a threejs project. I first thought it was due to a malformed exported file and yes the file has some issues, but checking against blender 2.79 it worked
I could provide it if really needed but with basic example the problem stays the same.

The traceback indicates unique_name, I tried naming objects and the problem was gone.
I think it's a bug because as you said it's not mentioned in the spec and other 3D softwares have no problem opening those files.

Here you can check other .obj produced by threejs . I made 2 files from the "multiple" example with objects names (added by me, works) and without (default export, fails) so you can try:
named.obj unnamed.obj

I produced those 3 .obj files by hand with some [basic cube example ](https://fr.wikipedia.org/wiki/Objet_3D_(format_de_fichier)) to illustrate the problem. I noticed this while working on a [threejs ](https://threejs.org) project. I first thought it was due to a malformed exported file and yes the file has some issues, but checking against blender 2.79 it worked I could provide it if really needed but with basic example the problem stays the same. The traceback indicates unique_name, I tried naming objects and the problem was gone. I think it's a bug because as you said it's not mentioned in the spec and other 3D softwares have no problem opening those files. Here you can check [other .obj produced by threejs ](https://threejs.org/examples/misc_exporter_obj.html). I made 2 files from the "multiple" example with objects names (added by me, works) and without (default export, fails) so you can try: [named.obj](https://archive.blender.org/developer/F7628360/named.obj) [unnamed.obj](https://archive.blender.org/developer/F7628361/unnamed.obj)

The behavior in 2.79b is different, but the import of multiple unnamed objects doesn't work there either. It just imports one of them.
Now the question is whether your handcrafted files are considered valid .obj format and therefore should be supported. That isn't my call to make, one of the devs or project owners has to decide.

The behavior in 2.79b is different, but the import of multiple unnamed objects doesn't work there either. It just imports one of them. Now the question is whether your handcrafted files are considered valid .obj format and therefore should be supported. That isn't my call to make, one of the devs or project owners has to decide.
Author

the import of multiple unnamed objects doesn't work there either. It just imports one of them.

@rjg You're right, it doesn't work the same but at least it imports something :)

> the import of multiple unnamed objects doesn't work there either. It just imports one of them. @rjg You're right, it doesn't work the same but at least it imports something :)
Bastien Montagne self-assigned this 2019-07-26 11:31:36 +02:00

Will check how to handle multiple unamed objects...

Will check how to handle multiple unamed objects...

This issue was referenced by blender/blender-addons@5f579088bb

This issue was referenced by blender/blender-addons@5f579088bba5bf9869651c6f622fd85bbf59edc7

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 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#67673
No description provided.