How to access Alembic format class

Hello Community !

I’m trying to access the Import classes for all formats supported by blender. Most of them are accessible from bpy.types :

bpy.types.IMPORT_ANIM_OT_bvh
bpy.types.IMPORT_CURVE_OT_svg
bpy.types.IMPORT_IMAGE_OT_to_plane
bpy.types.IMPORT_MESH_OT_ply
bpy.types.IMPORT_MESH_OT_stl
bpy.types.IMPORT_SCENE_OT_fbx
bpy.types.IMPORT_SCENE_OT_gltf
bpy.types.IMPORT_SCENE_OT_obj
bpy.types.IMPORT_SCENE_OT_x3d

It is really convenient because I can access to all the import parameters as well, for exemple :

for k,v in bpy.types.IMPORT_SCENE_OT_obj.__annotations__.items():
    print(k, v)

The issue I have is that some formats are not in the located in bpy.types apparently. I’m looking for the class for :

  • ABC Format
  • DAE Format

Is there any way I can access to these classes and its import parameters in Python ?

Thanks in advance,

Cheers

The Alembic, Collada, and USD im/exporters are implemented in C++. This means that they’re only exposed as an operator (bpy.ops.wm.alembic_import() for example).

The good news is that all operators can be introspected directly, rather than having to through bpy.types.XXX_OT_yyy classes:

>>> rna_type = bpy.ops.wm.alembic_export.get_rna_type()
>>> list(rna_type.properties)
[<bpy_struct, PointerProperty("rna_type") at 0x00007FF6C4EE4710>,
 <bpy_struct, StringProperty("filepath") at 0x0000021A6CCB3628>,
 <bpy_struct, BoolProperty("check_existing") at 0x0000021A6CCB2BE8>,
 <bpy_struct, BoolProperty("filter_blender") at 0x0000021A6CCB25F8>,
 <bpy_struct, BoolProperty("filter_backup") at 0x0000021A6CCB2728>,
 <bpy_struct, BoolProperty("filter_image") at 0x0000021A6CCB2D18>,
 <bpy_struct, BoolProperty("filter_movie") at 0x0000021A6CCB2988>,
 <bpy_struct, BoolProperty("filter_python") at 0x0000021A6CCB2AB8>,
 <bpy_struct, BoolProperty("filter_font") at 0x0000021A6CCA7FB8>,
 <bpy_struct, BoolProperty("filter_sound") at 0x0000021A6CCA5628>,
 <bpy_struct, BoolProperty("filter_text") at 0x0000021A6CCA3AD8>,
 <bpy_struct, BoolProperty("filter_archive") at 0x0000021A6CCA7638>,
 <bpy_struct, BoolProperty("filter_btx") at 0x0000021A6CCA7768>,
 <bpy_struct, BoolProperty("filter_collada") at 0x0000021A6CCA4588>,
 <bpy_struct, BoolProperty("filter_alembic") at 0x0000021A6CCA4458>,
 <bpy_struct, BoolProperty("filter_usd") at 0x0000021A6CCA5038>,
 <bpy_struct, BoolProperty("filter_volume") at 0x0000021A6CCA7508>,
 <bpy_struct, BoolProperty("filter_folder") at 0x0000021A6CCA46B8>,
 <bpy_struct, BoolProperty("filter_blenlib") at 0x0000021A6CCA6A58>,
 <bpy_struct, IntProperty("filemode") at 0x0000021A6CC915B8>,
 <bpy_struct, EnumProperty("display_type") at 0x0000021A6CCB4CA8>,
 <bpy_struct, EnumProperty("sort_method") at 0x0000021A6CCB5C68>,
 <bpy_struct, IntProperty("start") at 0x0000021A6CC91318>,
 <bpy_struct, IntProperty("end") at 0x0000021A6CC92038>,
 <bpy_struct, IntProperty("xsamples") at 0x0000021A6CC92C08>,
 <bpy_struct, IntProperty("gsamples") at 0x0000021A6CC91708>,
 <bpy_struct, FloatProperty("sh_open") at 0x0000021A6CC909E8>,
 <bpy_struct, FloatProperty("sh_close") at 0x0000021A6CC91858>,
 <bpy_struct, BoolProperty("selected") at 0x0000021A6CCA5758>,
 <bpy_struct, BoolProperty("renderable_only") at 0x0000021A6CCA4F08>,
 <bpy_struct, BoolProperty("visible_objects_only") at 0x0000021A6CCA47E8>,
 <bpy_struct, BoolProperty("flatten") at 0x0000021A6CCA79C8>,
 <bpy_struct, BoolProperty("uvs") at 0x0000021A6CCA41F8>,
 <bpy_struct, BoolProperty("packuv") at 0x0000021A6CCA6928>,
 <bpy_struct, BoolProperty("normals") at 0x0000021A6CCA3C08>,
 <bpy_struct, BoolProperty("vcolors") at 0x0000021A6CCA7E88>,
 <bpy_struct, BoolProperty("orcos") at 0x0000021A6CCA5168>,
 <bpy_struct, BoolProperty("face_sets") at 0x0000021A6CCA4918>,
 <bpy_struct, BoolProperty("subdiv_schema") at 0x0000021A6CCA6338>,
 <bpy_struct, BoolProperty("apply_subdiv") at 0x0000021A6CCA4CA8>,
 <bpy_struct, BoolProperty("curves_as_mesh") at 0x0000021A6CCA7AF8>,
 <bpy_struct, BoolProperty("use_instancing") at 0x0000021A6CCA5D48>,
 <bpy_struct, FloatProperty("global_scale") at 0x0000021A6CC92D58>,
 <bpy_struct, BoolProperty("triangulate") at 0x0000021A6CCA80E8>,
 <bpy_struct, EnumProperty("quad_method") at 0x0000021A6CCB3988>,
 <bpy_struct, EnumProperty("ngon_method") at 0x0000021A6CCB5D88>,
 <bpy_struct, BoolProperty("export_hair") at 0x0000021A6CCA4A48>,
 <bpy_struct, BoolProperty("export_particles") at 0x0000021A6CCA7898>,
 <bpy_struct, BoolProperty("export_custom_properties") at 0x0000021A6CCA4328>,
 <bpy_struct, BoolProperty("as_background_job") at 0x0000021A6CCA6598>,
 <bpy_struct, BoolProperty("init_scene_frame_range") at 0x0000021A6CCA4B78>]

Many thanks @sybren for taking the time to answer me. It is indeed a more straightforward and universal way to access the parameters.
But unfortunately I’m still struggling to use the parameters the same way I did when getting them with the class annotations.
To be more specific : I’m trying to draw all parameters in the UI.

  • Using the class annotations, I’m getting _PropertyDeferred data that can be directly reused in the draw method of the operator
  • Using the get_rna_types, I’m getting a bpy_struct data and I don’t really know how I can draw them the same way.

Here is a more in depth exemple of how I’m trying to use it :

    import bpy
    bl_info = {
        "name": "import_settings",
        "version": (1, 0, 0),
        "blender": (2, 80, 0),
    }

    class OBJ_Properties(bpy.types.PropertyGroup):
        name : bpy.props.StringProperty(name='name', default='OBJ')

    class ABC_Properties(bpy.types.PropertyGroup):
        name : bpy.props.StringProperty(name='name', default='ABC')

    for k,v in bpy.types.IMPORT_SCENE_OT_obj.__annotations__.items():
        OBJ_Properties.__annotations__[k] = v

    for k,v in bpy.ops.wm.alembic_import.get_rna_type().properties.items():
        ABC_Properties.__annotations__[k] = v

    classes = (OBJ_Properties,
               ABC_Properties)

    class Import_Settings(bpy.types.Operator):
        bl_idname = "import_scene.import_settings"
        bl_label = "Import Settings"
        bl_options = {'REGISTER'}
        bl_region_type = "UI"
        format_setting: 2

        def execute(self,context):
            return {'FINISHED'}

        def invoke(self, context, event):
            for c in classes:
                for k,v in c.__annotations__.items():
                    self.__class__.__annotations__[k] = v
            
            bpy.utils.unregister_class(Import_Settings)
            bpy.utils.register_class(Import_Settings)
            wm = context.window_manager
            return wm.invoke_props_dialog(self)

        def draw(self, context):
            layout = self.layout
            col = layout.column()
            
            # Draw OBJ Properties
            for k in OBJ_Properties.__annotations__.keys():
                if k == 'name':
                    continue

                col.prop(self, k)

            # Draw ABC Properties
            for k in ABC_Properties.__annotations__.keys():
                if k == 'name':
                    continue
                col.prop(self, k)

    def register():
        bpy.utils.register_class(Import_Settings)

    def unregister():
        bpy.utils.unregister_class(Import_Settings)

    if __name__ == "__main__":
        register()

To give more global context :

My overall goal is to create an addon to simplify the way to import files in blender. The user pick multiple files of any compatible format from an import dialog. The addon get and draw to the user the import settings of each format selected, and then batch import all the files.

My objective is to achieve it witout hardcoding any import parameter for scalability and to facilitate maintenance in case an import format change for some reasons.

This is something that I have already achieve reading through the import class annotations to dynamically list and draw the parameters to the user but not yet for the C++ import classes as Alembic or Collada.
If you are curious, the last revision of the main branch should work properly on my github

I want to precise that I’m not a developper so my coding style might not be the best.

Here is a video to see it in action

Thanks