import_x3d.py crashes when no material is specified #95860

Closed
opened 2022-02-18 05:25:48 +01:00 by Daniel Scharstein · 4 comments

System Information
Operating system: macOS-12.1-x86_64-i386-64bit 64 Bits
Graphics card: AMD Radeon Pro 5500M OpenGL Engine ATI Technologies Inc. 4.1 ATI-4.7.101

Blender Version
Broken: version: 3.0.1, branch: master, commit date: 2022-01-25 17:19, hash: blender/blender@dc2d180181

Short description of error

When an x3d (.wrl) file is imported that doesn't specify a default material, the importer crashes with the message

  ...{F12872081}

{F12872082}
  File "/Applications/Blender.app/Contents/Resources/3.0/scripts/addons/io_scene_x3d/import_x3d.py", line 2764, in appearance_CreateDefaultMaterial
    bpymat_wrap.base_color = (0.8, 0.8, 0.8, 1.0)
  File "/Applications/Blender.app/Contents/Resources/3.0/scripts/modules/bpy_extras/node_shader_utils.py", line 36, in wrapper
    return func(self, *args, **kwargs)
  File "/Applications/Blender.app/Contents/Resources/3.0/scripts/modules/bpy_extras/node_shader_utils.py", line 277, in base_color_set
    self.material.diffuse_color = color
ValueError: bpy_struct: item.attr = val: sequences of dimension 0 should contain 4 items, not 5

The easy fix is to change line 2764 in addons/io_scene_x3d/import_x3d.py to provide only 3 values, not 4:

2764c2764
<     bpymat_wrap.base_color = (0.8, 0.8, 0.8, 1.0)
---
>     bpymat_wrap.base_color = (0.8, 0.8, 0.8)

Exact steps for others to reproduce the error

Import the attached file crash_without_material.wrl: File -> Import -> X3D Extensible 3D (.x3d/.wrl)
Given that #material Material { } is commented out it crashes the importer.

crash_without_material.wrl

**System Information** Operating system: macOS-12.1-x86_64-i386-64bit 64 Bits Graphics card: AMD Radeon Pro 5500M OpenGL Engine ATI Technologies Inc. 4.1 ATI-4.7.101 **Blender Version** Broken: version: 3.0.1, branch: master, commit date: 2022-01-25 17:19, hash: `blender/blender@dc2d180181` **Short description of error** When an x3d (.wrl) file is imported that doesn't specify a default material, the importer crashes with the message ``` ...{F12872081} {F12872082} File "/Applications/Blender.app/Contents/Resources/3.0/scripts/addons/io_scene_x3d/import_x3d.py", line 2764, in appearance_CreateDefaultMaterial bpymat_wrap.base_color = (0.8, 0.8, 0.8, 1.0) File "/Applications/Blender.app/Contents/Resources/3.0/scripts/modules/bpy_extras/node_shader_utils.py", line 36, in wrapper return func(self, *args, **kwargs) File "/Applications/Blender.app/Contents/Resources/3.0/scripts/modules/bpy_extras/node_shader_utils.py", line 277, in base_color_set self.material.diffuse_color = color ValueError: bpy_struct: item.attr = val: sequences of dimension 0 should contain 4 items, not 5 ``` The easy fix is to change line 2764 in `addons/io_scene_x3d/import_x3d.py` to provide only 3 values, not 4: ``` 2764c2764 < bpymat_wrap.base_color = (0.8, 0.8, 0.8, 1.0) --- > bpymat_wrap.base_color = (0.8, 0.8, 0.8) ``` **Exact steps for others to reproduce the error** Import the attached file `crash_without_material.wrl`: File -> Import -> X3D Extensible 3D (.x3d/.wrl) Given that `#material Material { }` is commented out it crashes the importer. [crash_without_material.wrl](https://archive.blender.org/developer/F12872096/crash_without_material.wrl)

Added subscriber: @dscharstein

Added subscriber: @dscharstein
Member

Added subscriber: @PratikPB2123

Added subscriber: @PratikPB2123
Member

This issue has been reported before so I will mark it as duplicate of #95455 (Exception raised and failure in importing an X3D file with no Material node)
Thanks for the report!

This issue has been reported before so I will mark it as duplicate of #95455 (Exception raised and failure in importing an X3D file with no Material node) Thanks for the report!
Member

Closed as duplicate of #95455

Closed as duplicate of #95455
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 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#95860
No description provided.