From 1c4967bd67b7788e1aec4e7f800f87d68479312f Mon Sep 17 00:00:00 2001 From: Colin Basnett Date: Mon, 9 Sep 2024 16:29:20 -0700 Subject: [PATCH] Fixed `is_bdk_addon_loaded` function --- io_scene_psk_psa/psk/importer.py | 3 ++- io_scene_psk_psa/shared/helpers.py | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/io_scene_psk_psa/psk/importer.py b/io_scene_psk_psa/psk/importer.py index 6464d2b..c2f3348 100644 --- a/io_scene_psk_psa/psk/importer.py +++ b/io_scene_psk_psa/psk/importer.py @@ -131,7 +131,8 @@ def import_psk(psk: Psk, context, options: PskImportOptions) -> PskImportResult: # Material does not yet exist, and we have the BDK addon installed. # Attempt to load it using BDK addon's operator. material_reference = psk.material_references[material_index] - if material_reference and bpy.ops.bdk.link_material(reference=material_reference, repository_id=options.bdk_repository_id) == {'FINISHED'}: + repository_id = options.bdk_repository_id if options.bdk_repository_id is not None else '' + if material_reference and bpy.ops.bdk.link_material(reference=material_reference, repository_id=repository_id) == {'FINISHED'}: material = bpy.data.materials[material_name] else: # Just create a blank material. diff --git a/io_scene_psk_psa/shared/helpers.py b/io_scene_psk_psa/shared/helpers.py index ba3cff2..b8ba47e 100644 --- a/io_scene_psk_psa/shared/helpers.py +++ b/io_scene_psk_psa/shared/helpers.py @@ -163,7 +163,5 @@ def get_export_bone_names(armature_object: Object, bone_filter_mode: str, bone_c return bone_names -def is_bdk_addon_loaded(): - # TODO: this does not work anymore for *reasons*. Just check if bpy.ops.bdk.link_material exists. - # return addon_utils.check('bdk_addon')[1] - return bpy.ops.bdk.link_material is not None +def is_bdk_addon_loaded() -> bool: + return bpy.ops.bdk is not None and bpy.ops.bdk.link_material is not None