diff --git a/io_scene_psk_psa/psk/import_/operators.py b/io_scene_psk_psa/psk/import_/operators.py index 8d9dad2..b8ce7c9 100644 --- a/io_scene_psk_psa/psk/import_/operators.py +++ b/io_scene_psk_psa/psk/import_/operators.py @@ -101,6 +101,12 @@ class PSK_OT_import(Operator, ImportHelper): default=1.0, soft_min=0.0, ) + bdk_repository_id: StringProperty( + name='BDK Repository ID', + default='', + options=empty_set, + description='The ID of the BDK repository to use for loading materials' + ) def execute(self, context): psk = read_psk(self.filepath) @@ -118,6 +124,9 @@ class PSK_OT_import(Operator, ImportHelper): options.should_import_shape_keys = self.should_import_shape_keys options.scale = self.scale + if self.bdk_repository_id: + options.bdk_repository_id = self.bdk_repository_id + if not options.should_import_mesh and not options.should_import_skeleton: self.report({'ERROR'}, 'Nothing to import') return {'CANCELLED'} diff --git a/io_scene_psk_psa/psk/importer.py b/io_scene_psk_psa/psk/importer.py index de8ddc7..6464d2b 100644 --- a/io_scene_psk_psa/psk/importer.py +++ b/io_scene_psk_psa/psk/importer.py @@ -25,6 +25,7 @@ class PskImportOptions: self.bone_length = 1.0 self.should_import_materials = True self.scale = 1.0 + self.bdk_repository_id = None class ImportBone: @@ -130,7 +131,7 @@ 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) == {'FINISHED'}: + if material_reference and bpy.ops.bdk.link_material(reference=material_reference, repository_id=options.bdk_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 f778e1e..ba3cff2 100644 --- a/io_scene_psk_psa/shared/helpers.py +++ b/io_scene_psk_psa/shared/helpers.py @@ -2,7 +2,6 @@ import re import typing from typing import List, Iterable -import addon_utils import bpy.types from bpy.types import NlaStrip, Object, AnimData @@ -165,4 +164,6 @@ def get_export_bone_names(armature_object: Object, bone_filter_mode: str, bone_c def is_bdk_addon_loaded(): - return addon_utils.check('bdk_addon')[1] + # 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