0
$\begingroup$

How do I get a list of default properties for an operator, similar to how the console autofill does, so bpy.ops.export_scene.fbx() gives:

check_existing=True,
filter_glob="*.fbx",
use_selection=False,
...

$\endgroup$
1
  • $\begingroup$ You can peek into the scripts in the /addons folder $\endgroup$ – Gorgious Mar 25 at 9:03
1
$\begingroup$

Operator property variables are defined as Python class annotations, so you can read those to find their defaults.

First, get the name of the class as registered:

>>> bpy.ops.export_scene.fbx.idname()
'EXPORT_SCENE_OT_fbx'

Then use that to get operator class as defined in the script file:

>>> getattr(bpy.types, bpy.ops.export_scene.fbx.idname())
<class 'io_scene_fbx.ExportFBX'>

And lastly, read the type annotations on that:

>>> getattr(bpy.types, bpy.ops.export_scene.fbx.idname()).__annotations__

The results from this are a little long and also include information like minimum and maximum permissible values, so you may want to filter them through a dict comprehension to get something easier to use:

>>> {k:v[1].get("default", None) for k, v in getattr(bpy.types, bpy.ops.export_scene.fbx.idname()).__annotations__.items()}
{'filter_glob': '*.fbx', 'use_selection': False, 'use_active_collection': False, 'global_scale': 1.0, 'apply_unit_scale': True, 'apply_scale_options': None, 'use_space_transform': True, 'bake_space_transform': False, 'object_types': {'CAMERA', 'EMPTY', 'ARMATURE', 'OTHER', 'MESH', 'LIGHT'}, 'use_mesh_modifiers': True, 'use_mesh_modifiers_render': True, 'mesh_smooth_type': 'OFF', 'use_subsurf': False, 'use_mesh_edges': False, 'use_tspace': False, 'use_custom_props': False, 'add_leaf_bones': True, 'primary_bone_axis': 'Y', 'secondary_bone_axis': 'X', 'use_armature_deform_only': False, 'armature_nodetype': 'NULL', 'bake_anim': True, 'bake_anim_use_all_bones': True, 'bake_anim_use_nla_strips': True, 'bake_anim_use_all_actions': True, 'bake_anim_force_startend_keying': True, 'bake_anim_step': 1.0, 'bake_anim_simplify_factor': 1.0, 'path_mode': 'AUTO', 'embed_textures': False, 'batch_mode': None, 'use_batch_own_dir': True, 'use_metadata': True, 'axis_forward': '-Z', 'axis_up': 'Y'}
$\endgroup$
0
$\begingroup$

Found out it was idname,
print(bpy.ops.export_scene.fbx.idname)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.