ezc3d icon indicating copy to clipboard operation
ezc3d copied to clipboard

KeyError (__METADATA__) on adding events on a fresh c3d file

Open felixchenier opened this issue 2 years ago • 0 comments

Salut encore Benjamin

I have a problem when trying to add events to a new c3d file.

You python unit test for c3d.add_event() works well:

  1. Reading a c3d file without events
  2. Adding events to it using c3d.add_event()
  3. Saving using c3d.write()

I also have luck with this:

  1. Creating a fresh c3d instance and add some stuff in it
  2. Saving using c3d.write()

But I can't add events to a fresh c3d instance:

  1. Creating a fresh c3d instance and add some stuff in it
  2. Adding events to it using c3d.add_event()
  3. Saving using c3d.write()
  File "/Users/felix/miniconda3/envs/mosa/lib/python3.8/site-packages/ezc3d/__init__.py", line 553, in write
    new_c3d.parameters().group(group).description(groups[group]["__METADATA__"]["DESCRIPTION"])

KeyError: '__METADATA__'

I think that the METADATA key is not created by the c3d constructor, it may be only created on a read_c3d() call.

My workaround for now is to create the c3d instance, add everything to it but no event, save it, read it, add the events, save it again. This works but obviously this is not what we'd expect.

À+

felixchenier avatar Aug 05 '22 14:08 felixchenier