json2fbx.py script creates invalid FBX 7500 files #104684

Closed
opened 2023-06-09 21:42:16 +02:00 by Thomas Barlow · 0 comments
Member

System Information
Operating system: Windows-10-10.0.19045-SP0 64 Bits
Graphics card: NVIDIA GeForce GTX 1070 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 531.41

Blender Version
Broken: version: 4.0.0 Alpha, branch: main, commit date: 2023-05-24 15:26, hash: 9acff4edabe5
Worked:

Addon Information
Name: FBX format (5, 3, 0)
Author: Campbell Barton, Bastien Montagne, Jens Restemeier, @Mysteryem

Short description of error
When the json2fbx.py script creates an FBX version 7500 .fbx file, the resultant file is invalid.

This happens because there are binary changes between FBX versions 7400 and 7500.

The fbx2json.py script and Blender's FBX importer are capable of handling FBX 7500 files, but because the json2fbx.py script shares much of its code with Blender's FBX exporter and Blender's exporter always writes FBX version 7400 files, the json2fbx.py script always writes a 7400 binary, even if the .json specified that the file is version 7500.

Exact steps for others to reproduce the error

  1. Export an .fbx from Blender
  2. Convert the exported .fbx to json with fbx2json.py
  3. Modify the FBXVersion in the .json file to 7500
  4. Convert the modified .json to .fbx
  5. Attempt to import the new .fbx into Blender (or other external software)
  6. Observe that a MemoryError likely occurs because Blender tries to read the file as if it were FBX version 7500, but the binary does not match and the read prop_count variable ends up huge (external software will likely say that the file is corrupt).
Traceback (most recent call last):
  File "G:\blender-git\build_windows_x64_vc17_Release\bin\Release\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 2648, in load
    elem_root, version = parse_fbx.parse(filepath)
  File "G:\blender-git\build_windows_x64_vc17_Release\bin\Release\4.0\scripts\addons\io_scene_fbx\parse_fbx.py", line 170, in parse
    elem = read_elem(read, tell, use_namedtuple)
  File "G:\blender-git\build_windows_x64_vc17_Release\bin\Release\4.0\scripts\addons\io_scene_fbx\parse_fbx.py", line 118, in read_elem
    elem_props_type = bytearray(prop_count)  # elem property types
MemoryError

Attached is an exported cube.fbx, and two .json files created from it with fbx2json.py, one of which has had its FBXVersion modified to 7500. The .fbx files created by json2fbx from each .json are also attached.

**System Information** Operating system: Windows-10-10.0.19045-SP0 64 Bits Graphics card: NVIDIA GeForce GTX 1070 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 531.41 **Blender Version** Broken: version: 4.0.0 Alpha, branch: main, commit date: 2023-05-24 15:26, hash: `9acff4edabe5` Worked: **Addon Information** Name: FBX format (5, 3, 0) Author: Campbell Barton, Bastien Montagne, Jens Restemeier, @Mysteryem **Short description of error** When the `json2fbx.py` script creates an FBX version 7500 .fbx file, the resultant file is invalid. This happens because there are binary changes between FBX versions 7400 and 7500. The `fbx2json.py` script and Blender's FBX importer are capable of handling FBX 7500 files, but because the `json2fbx.py` script shares much of its code with Blender's FBX exporter and Blender's exporter always writes FBX version 7400 files, the `json2fbx.py` script always writes a 7400 binary, even if the .json specified that the file is version 7500. **Exact steps for others to reproduce the error** 1. Export an .fbx from Blender 1. Convert the exported .fbx to json with `fbx2json.py` 1. Modify the `FBXVersion` in the .json file to `7500` 1. Convert the modified .json to .fbx 1. Attempt to import the new .fbx into Blender (or other external software) 1. Observe that a `MemoryError` likely occurs because Blender tries to read the file as if it were FBX version 7500, but the binary does not match and the read `prop_count` variable ends up huge (external software will likely say that the file is corrupt). ``` Traceback (most recent call last): File "G:\blender-git\build_windows_x64_vc17_Release\bin\Release\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 2648, in load elem_root, version = parse_fbx.parse(filepath) File "G:\blender-git\build_windows_x64_vc17_Release\bin\Release\4.0\scripts\addons\io_scene_fbx\parse_fbx.py", line 170, in parse elem = read_elem(read, tell, use_namedtuple) File "G:\blender-git\build_windows_x64_vc17_Release\bin\Release\4.0\scripts\addons\io_scene_fbx\parse_fbx.py", line 118, in read_elem elem_props_type = bytearray(prop_count) # elem property types MemoryError ``` Attached is an exported cube.fbx, and two .json files created from it with `fbx2json.py`, one of which has had its FBXVersion modified to 7500. The .fbx files created by `json2fbx` from each .json are also attached.
Thomas Barlow added the
Type
Report
Priority
Normal
Status
Needs Triage
labels 2023-06-09 21:42:17 +02:00
Blender Bot added
Status
Resolved
and removed
Status
Needs Triage
labels 2023-09-26 03:57:22 +02:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 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#104684
No description provided.