2025-12-01

This commit is contained in:
2026-03-17 14:58:51 -06:00
parent 183e865f8b
commit 4b82b57113
6846 changed files with 954887 additions and 162606 deletions
@@ -38,6 +38,7 @@ from ..modules.poliigon_core.assets import (
AssetType)
from ..modules.poliigon_core.multilingual import _t
from ..material_import_utils import ASSET_TYPE_TO_IMPORTED_TYPE
from ..constants import ASSET_ID_ALL
from ..toolbox import get_context
from .. import reporting
from .asset_browser_sync_commands import (
@@ -466,10 +467,16 @@ class POLIIGON_OT_sync_client(Operator):
asset_categories.remove(asset_type_cat)
category_list = [asset_type_cat]
cat_slug = ""
for cat in asset_categories:
cat = cat.title()
cat_slug += "/" + cat
for _id_category in asset_categories:
cat_path = cTB.category_ids.get(_id_category, None)
if cat_path is None:
continue
sub_cats = cat_path.split("/")[2:] # skip asset type
if len(sub_cats) == 0:
continue
sub_cats = [_cat.replace("-", " ").title() for _cat in sub_cats]
cat = sub_cats[-1]
cat_slug = "/" + "/".join(sub_cats)
if cat_slug not in ctx.poliigon_categories[asset_type_cat]:
break
category_list.append(cat)
@@ -491,6 +498,7 @@ class POLIIGON_OT_sync_client(Operator):
ctx, asset_data)
# After this loop uuid_result contains the UUID of the leaf catalog
uuid_result = None
for idx_cat, category in enumerate(asset_categories):
category_path = "/".join(asset_categories[:idx_cat + 1])
if category_path not in catalog_dict:
@@ -507,6 +515,10 @@ class POLIIGON_OT_sync_client(Operator):
cTB.logger_ab.debug("add_catalog(): Failed to write catalog file")
return False
if not uuid_result:
print("Failed to assign meta, but returning positive to continue")
return False
# Finally assign the determined UUID to the entity
entity.asset_data.catalog_id = uuid_result
return True
@@ -532,9 +544,27 @@ class POLIIGON_OT_sync_client(Operator):
entity.asset_data.tags.new(asset_display_name)
entity.asset_data.tags.new(asset_name) # unique name
entity.asset_data.tags.new("Poliigon")
for category in asset_data.categories:
category_names = []
for _id_category in asset_data.categories:
# TODO(Andreas): maybe we want to filter free?
entity.asset_data.tags.new(category.title())
cat_path = cTB.category_ids.get(_id_category, None)
if cat_path is None:
cTB.logger_ab.error("UNKNOWN CATEGORY_ID: ", _id_category)
continue
# [:1] - Skip initial "/" to avoid empty list entry upon split
cat_names = cat_path[1:].split("/")
category_names.extend(cat_names)
category_names = list(set(category_names))
if len(category_names) == 0:
asset_type_cat = ASSET_TYPE_TO_IMPORTED_TYPE[asset_type]
category_names = [asset_type_cat]
for _category in category_names:
entity.asset_data.tags.new(_category.title())
if asset_type == AssetType.HDRI:
entity.asset_data.tags.new(params["size"])
@@ -844,13 +874,15 @@ class POLIIGON_OT_sync_client(Operator):
asset_id = cmd.data["asset_id"]
asset_data = cTB._asset_index.get_asset(asset_id)
if asset_data is None:
if asset_data is None or not asset_data.is_local or not asset_data.is_purchased:
bpy.ops.poliigon.get_local_asset_sync(
await_startup_poliigon=False,
await_startup_my_assets=False,
get_poliigon=False,
get_my_assets=True,
asset_id=asset_id,
# Andreas: With API V2 rather not search for an asset ID but
# initiate a My Assets job instead.
asset_id=ASSET_ID_ALL,
abort_ongoing_jobs=False)
asset_data = cTB._asset_index.get_asset(asset_id)
@@ -885,7 +917,7 @@ class POLIIGON_OT_sync_client(Operator):
await_startup_poliigon=False,
await_startup_my_assets=True,
get_poliigon=False,
get_my_assets=False,
get_my_assets=True,
abort_ongoing_jobs=False)
ctx.queue_send.put(SyncAssetBrowserCmd(code=SyncCmd.HELLO))
@@ -123,6 +123,8 @@ class POLIIGON_PT_sidebar_left(bpy.types.Panel):
def poll(self, context):
if not cTB.is_logged_in():
return False
if not cTB.user_legacy_own_assets():
return False
if not is_asset_browser(context):
return False
if not is_poliigon_library(context, incl_all_libs=False):
@@ -136,7 +138,7 @@ class POLIIGON_PT_sidebar_left(bpy.types.Panel):
if not self.view_screen_tracked:
# TODO(patrick): value not retained, re-triggering on future draws
self.view_screen_tracked = True
cTB.track_screen("blend_browser_lib")
cTB.signal_view_screen("blend_browser_lib")
layout = self.layout
box = layout.box()
@@ -192,7 +194,7 @@ class POLIIGON_PT_sidebar_right(bpy.types.Panel):
return
if not self.view_screen_tracked:
cTB.track_screen("blend_browser_import")
cTB.signal_view_screen("blend_browser_import")
self.view_screen_tracked = True
num_selected = get_num_selected_assets(context)