Blender Kitsu: New Assset Tagging System #286
@ -33,28 +33,32 @@ def get_shot_assets(
|
|||||||
asset_index = get_assset_index()
|
asset_index = get_assset_index()
|
||||||
if asset_index is None:
|
if asset_index is None:
|
||||||
return
|
return
|
||||||
assets = shot.get_all_assets()
|
kitsu_assets = shot.get_all_assets()
|
||||||
asset_slugs = [asset.data.get("slug") for asset in assets if asset.data.get("slug") is not None]
|
|
||||||
if asset_slugs == []:
|
for kitsu_asset in kitsu_assets:
|
||||||
print("No asset slugs found on Kitsu Server. Assets will not be loaded")
|
asset_path = kitsu_asset.data.get("filepath")
|
||||||
for key, value in asset_index.items():
|
collection_name = kitsu_asset.data.get("collection")
|
||||||
if key in asset_slugs:
|
if not asset_path or not collection_name:
|
||||||
relative_path = value.get('filepath')
|
print(
|
||||||
asset_dir = get_asset_dir()
|
f"Asset '{kitsu_asset.name}' is missing filepath or collection metadata. Skipping"
|
||||||
filepath = Path(asset_dir).joinpath(relative_path).__str__()
|
)
|
||||||
data_type = value.get('type')
|
continue
|
||||||
if config.ASSET_TYPE_TO_OVERRIDE.get(key.split('-')[0]):
|
|
||||||
if data_type != "Collection":
|
filepath = prefs.project_root_dir_get(bpy.context).joinpath(asset_path).absolute()
|
||||||
print(f"Cannot load {key} because it is not a collection")
|
if not filepath.exists():
|
||||||
continue
|
print(f"Asset '{kitsu_asset.name}' filepath '{str(filepath)}' does not exist. Skipping")
|
||||||
linked_collection = core.link_and_override_collection(
|
|
||||||
collection_name=key, file_path=filepath, scene=scene
|
if config.ASSET_TYPE_TO_OVERRIDE.get(collection_name.split('-')[0]):
|
||||||
)
|
linked_collection = core.link_and_override_collection(
|
||||||
core.add_action_to_armature(linked_collection, shot)
|
collection_name=collection_name, file_path=str(filepath), scene=scene
|
||||||
print(f"'{key}': Succesfully Linked & Overriden")
|
)
|
||||||
else:
|
core.add_action_to_armature(linked_collection, shot)
|
||||||
linked_collection = core.link_data_block(
|
print(f"'{collection_name}': Succesfully Linked & Overriden")
|
||||||
file_path=filepath, data_block_name=key, data_block_type=data_type
|
else:
|
||||||
)
|
linked_collection = core.link_data_block(
|
||||||
print(f"'{key}': Succesfully Linked")
|
file_path=str(filepath),
|
||||||
output_collection.children.link(linked_collection)
|
data_block_name=collection_name,
|
||||||
|
data_block_type="Collection",
|
||||||
|
)
|
||||||
|
print(f"'{collection_name}': Succesfully Linked")
|
||||||
|
output_collection.children.link(linked_collection)
|
||||||
|
Loading…
Reference in New Issue
Block a user