2024-05-15 11:25:30 +00:00
|
|
|
import json
|
|
|
|
|
2024-05-16 12:09:40 +00:00
|
|
|
def get_user_assets(scene_or_collection):
|
|
|
|
user_assets = getattr(scene_or_collection, 'user_assets', [])
|
|
|
|
return user_assets
|
2024-05-15 21:32:01 +00:00
|
|
|
|
2024-05-16 12:09:40 +00:00
|
|
|
def get_generated_assets(scene_or_collection):
|
|
|
|
generated_assets = []
|
|
|
|
return generated_assets
|
|
|
|
|
|
|
|
def get_user_assets_as_list(scene_or_collection):
|
|
|
|
raw = get_user_assets(scene_or_collection)
|
|
|
|
result = []
|
|
|
|
for asset in raw:
|
|
|
|
result.append({"name": asset.name, "path": asset.path, "type": "MODEL", "internal": False, "parent": None})
|
|
|
|
return result
|
|
|
|
|
|
|
|
def upsert_asset(scene_or_collection, asset):
|
|
|
|
new_asset = scene_or_collection.user_assets.add()
|
|
|
|
new_asset.name = asset["name"]
|
|
|
|
new_asset.path = asset["path"]
|
|
|
|
|
|
|
|
def remove_asset(scene_or_collection, asset):
|
|
|
|
scene_or_collection.user_assets.remove(scene_or_collection.user_assets.find(asset["path"]))
|
|
|
|
|
|
|
|
def does_asset_exist(scene_or_collection, ref_asset):
|
|
|
|
user_assets = getattr(scene_or_collection, 'user_assets', [])
|
|
|
|
in_list = [asset for asset in user_assets if (asset.path == ref_asset["path"])]
|
2024-05-15 21:32:01 +00:00
|
|
|
in_list = len(in_list) > 0
|
|
|
|
return in_list
|