OBJ/MTL: import fails for .mtl files with texture options -o u v, -s u v #89421

Closed
opened 2021-06-25 03:26:17 +02:00 by Scurest · 11 comments

System Information
Operating system: Linux
Graphics card: Intel HD

Blender Version
Broken: 2.93
Worked:

Short description of error

MTL files allow textures to be scaled and offset with a texture option

-o u [v [w]]         # Origin offset    (default 0 0 0)
-s u [v [w]]         # Scale            (default 1 1 1)

v and w are optional, but importing currently fails with an exception for MTL files that omit v or w.

Exact steps for others to reproduce the error

Import this .obj file: MTLTextureOptionBug.zip

The important line is

map_Kd -o -0.5 -0.5 -s 2.0 2.0 WaterLilies.jpg

Details

The error is ultimately that the one- or two-element list is passed on to be assigned to the Mapping node's inputs

    self.node_mapping.inputs['Scale'].default_value = scale
ValueError: bpy_struct: item.attr = val: sequences of dimension 0 should contain 3 items, not 2

It can be fixed by expanding the list of offset/scale parameters to three elements around here .

For the relevant part of the MTL spec, open http://paulbourke.net/dataformats/mtl/ and Ctrl+F for "The -o option offsets".

Context

This was found at https://blender.stackexchange.com/questions/228486/import-obj-error-sequences-of-dimension-0-contain-3-items-not-2

**System Information** Operating system: Linux Graphics card: Intel HD **Blender Version** Broken: 2.93 Worked: **Short description of error** MTL files allow textures to be scaled and offset with a texture option ``` -o u [v [w]] # Origin offset (default 0 0 0) -s u [v [w]] # Scale (default 1 1 1) ``` v and w are optional, but importing currently fails with an exception for MTL files that omit v or w. **Exact steps for others to reproduce the error** Import this .obj file: [MTLTextureOptionBug.zip](https://archive.blender.org/developer/F10198386/MTLTextureOptionBug.zip) The important line is ``` map_Kd -o -0.5 -0.5 -s 2.0 2.0 WaterLilies.jpg ``` **Details** The error is ultimately that the one- or two-element list is passed on to be assigned to the Mapping node's inputs ``` self.node_mapping.inputs['Scale'].default_value = scale ValueError: bpy_struct: item.attr = val: sequences of dimension 0 should contain 3 items, not 2 ``` It can be fixed by expanding the list of offset/scale parameters to three elements around [here ](https://github.com/sobotka/blender-addons/blob/f86f25e62217264495d05f116ccb09d575fe9841/io_scene_obj/import_obj.py#L172-L175). For the relevant part of the MTL spec, open http://paulbourke.net/dataformats/mtl/ and Ctrl+F for "The -o option offsets". **Context** This was found at https://blender.stackexchange.com/questions/228486/import-obj-error-sequences-of-dimension-0-contain-3-items-not-2
Author

Added subscriber: @scurest

Added subscriber: @scurest

#95719 was marked as duplicate of this issue

#95719 was marked as duplicate of this issue

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

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

Added subscriber: @rjg

Added subscriber: @rjg
Member
Added subscribers: @Boostedbyniko, @lichtwerk, @ankitm, @StephenSwaney
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'

Added subscriber: @aras_p

Added subscriber: @aras_p
Aras Pranckevicius self-assigned this 2022-04-24 12:06:05 +02:00

Added subscribers: @TGlinskas, @EAW

Added subscribers: @TGlinskas, @EAW

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'

The new OBJ importer (experimental in 3.2, default in 3.3) handles this correctly. Now added test coverage to prove it as well.

The new OBJ importer (experimental in 3.2, default in 3.3) handles this correctly. Now added test coverage to prove it as well.
Author

@aras_p Great! I noticed it still seems to get confused by things like map_Kd -s 0.5 0.5 1.png though.

@aras_p Great! I noticed it still seems to get confused by things like `map_Kd -s 0.5 0.5 1.png` though.
Sign in to join this conversation.
No Milestone
No project
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#89421
No description provided.