EmbodiedCognition / py-c3d

Read & write C3D mocap files
http://c3d.rtfd.org
MIT License
104 stars 47 forks source link

Fails to read files with screen axis metadata #53

Closed Peaj closed 4 months ago

Peaj commented 5 months ago

When the c3d file contains screen axis metadata the file import fails with the following error:

Traceback (most recent call last):
  File "D:\Git\Blender\addons\io_anim_c3d\__init__.py", line 254, in execute
    msg = c3d_importer.load(self, context, filepath=path, **keywords)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Git\Blender\addons\io_anim_c3d\c3d_importer.py", line 97, in load
    global_orient, parsed_screen_param = parser.axis_interpretation([0, 0, 1], [0, 1, 0])
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Git\Blender\addons\io_anim_c3d\c3d_parse_dictionary.py", line 189, in axis_interpretation
    O_data[:, 0] = axis_x
    ~~~~~~^^^^^^
ValueError: could not convert string to float: '+Z'

The axis_interpretation method expects get_screen_axis to return vectors but get_screen_axis and set_screen_axis read and write the axis in string representation ("+Z", "-Y", etc.)

I am writing an exporter and used set_screen_axis to write the axis data to the file. When reimporting the file I encountered this error.

LeyangWen commented 5 months ago

Hi @Peaj, do you mind sharing the code segment where you got this error?

Peaj commented 4 months ago

Hi @LeyangWen,

I just found that axis_interpretation is not part of this repository. Sorry for the confusion. Its part of the blender c3d importer using this module: https://github.com/MattiasFredriksson/io_anim_c3d get and set_screen axis correctly assume the axis to be in string representation.

Thanks, Pascal