Asset Pipeline: Add Support for Asset Catalogs #185
@ -24,19 +24,20 @@ def find_asset_cat_file(directory):
|
||||
return find_asset_cat_file(parent_dir)
|
||||
|
||||
|
||||
def get_asset_cat_enum_items():
|
||||
def get_asset_cat_enum_items(reload: bool = False):
|
||||
global cat_data_cache
|
||||
if cat_data_cache is not None:
|
||||
if cat_data_cache is not None and not reload:
|
||||
return cat_data_cache
|
||||
items = []
|
||||
items.append(('NONE', 'None', ''))
|
||||
asset_cat_file = find_asset_cat_file(Path(bpy.data.filepath).parent.__str__())
|
||||
with (Path(asset_cat_file)).open() as file:
|
||||
for line in file.readlines():
|
||||
if line.startswith(("#", "VERSION", "\n")):
|
||||
continue
|
||||
# Each line contains : 'uuid:catalog_tree:catalog_name' + eol ('\n')
|
||||
name = line.split(':', 1)[1].strip('\n')
|
||||
name = line.split(':', 1)[1].split(":")[-1].strip("\n")
|
||||
uuid = line.split(':', 1)[0]
|
||||
|
||||
items.append((uuid, name, uuid))
|
||||
items.append((uuid, name, ''))
|
||||
return items
|
||||
|
@ -81,7 +81,7 @@ def create_next_published_file(
|
||||
asset_col = bpy.context.scene.asset_pipeline.asset_collection
|
||||
if publish_type == constants.ACTIVE_PUBLISH_KEY:
|
||||
asset_col.asset_mark()
|
||||
if catalog_id != '':
|
||||
if catalog_id != '' or catalog_id != 'NONE':
|
||||
asset_col.asset_data.catalog_id = catalog_id
|
||||
bpy.ops.wm.save_as_mainfile(filepath=new_file_path.__str__(), copy=True)
|
||||
asset_col.asset_clear()
|
||||
|
@ -1,6 +1,8 @@
|
||||
from typing import Set
|
||||
import bpy
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from . import constants
|
||||
from . import config
|
||||
from .prefs import get_addon_prefs
|
||||
@ -25,6 +27,8 @@ from .sync import (
|
||||
sync_execute_push,
|
||||
)
|
||||
|
||||
from .asset_catalog import get_asset_cat_enum_items
|
||||
|
||||
|
||||
class ASSETPIPE_OT_create_new_asset(bpy.types.Operator):
|
||||
bl_idname = "assetpipe.create_new_asset"
|
||||
@ -944,6 +948,17 @@ class ASSETPIPE_OT_batch_ownership_change(bpy.types.Operator):
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class ASSETPIPE_OT_refresh_asset_cat(bpy.types.Operator):
|
||||
bl_idname = "assetpipe.refresh_asset_cat"
|
||||
bl_label = "Refresh Asset Catalogs"
|
||||
bl_description = """Refresh Asset Catalogs"""
|
||||
|
||||
def execute(self, context: bpy.types.Context):
|
||||
get_asset_cat_enum_items()
|
||||
self.report({'INFO'}, "Asset Catalogs Refreshed!")
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
classes = (
|
||||
ASSETPIPE_OT_update_ownership,
|
||||
ASSETPIPE_OT_sync_push,
|
||||
@ -958,6 +973,7 @@ classes = (
|
||||
ASSETPIPE_OT_update_surrendered_object,
|
||||
ASSETPIPE_OT_update_surrendered_transfer_data,
|
||||
ASSETPIPE_OT_batch_ownership_change,
|
||||
ASSETPIPE_OT_refresh_asset_cat,
|
||||
)
|
||||
|
||||
|
||||
|
@ -179,7 +179,7 @@ def sync_execute_push(self, context):
|
||||
|
||||
asset_pipe = context.scene.asset_pipeline
|
||||
asset_col = asset_pipe.asset_collection
|
||||
if _catalog_id != '':
|
||||
if _catalog_id != '' or _catalog_id != 'NONE':
|
||||
asset_col.asset_data.catalog_id = _catalog_id
|
||||
|
||||
bpy.ops.wm.save_as_mainfile(filepath=file_path)
|
||||
|
Loading…
Reference in New Issue
Block a user