MattiasFredriksson / io_anim_c3d

Blender addon for importing .c3d files.
GNU General Public License v2.0
26 stars 5 forks source link

How to load c3d file with python API #7

Closed syKevinPeng closed 2 years ago

syKevinPeng commented 2 years ago

Hi,

Sorry to bombard you with questions. Could you please show me how to load c3d files with python API?

Best, Siyuan

MattiasFredriksson commented 2 years ago

Hey!

The following should work as long as the path is valid and the addon is enabled:

import bpy bpy.ops.import_anim.c3d(filepath="path/to/some/file.c3d", adapt_frame_rate=False)

Setting 'adapt_frame_rate=False' ensures keyframes are inserted in one frame increments. To find other arguments one can write

bpy.ops.import_anim.c3d(

in the Python Console window and press tab to get the operator declaration printed through the auto completion feature:

bpy.ops.import_anim.c3d(filepath="", directory="", filter_glob="*.c3d", files=[], adapt_frame_rate=True, fake_user=False, >include_event_markers=True, include_empty_labels=False, interpolation='BEZIER', max_residual=0, create_armature=True, >bone_size=0.02, global_scale=1, use_manual_orientation=False, print_file=False, axis_forward='-Z', axis_up='Y') Load a C3D file

If you are loading multiple files one might want to set 'create_armature=False' to avoid creating a new armature for each animation.

Happy blending, Mattias

syKevinPeng commented 2 years ago

Thanks, this resolved the problem.