Asset Pipeline v2 #145

Closed
Nick Alberelli wants to merge 431 commits from (deleted):feature/asset-pipeline-v2 into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
5 changed files with 52 additions and 63 deletions
Showing only changes of commit 40b2cba673 - Show all commits

View File

@ -127,7 +127,7 @@ class AssetTransferMapping:
def _gen_transfer_data_map(self):
transfer_data_map: Dict[bpy.types.Collection, bpy.types.Collection] = {}
temp_transfer_data = bpy.context.scene.temp_transfer_data_ownership
temp_transfer_data = bpy.context.scene.asset_pipeline.temp_transfer_data
for source_obj in self.object_map:
target_obj = self.object_map[source_obj]
objs = [source_obj, target_obj]

View File

@ -114,7 +114,7 @@ def merge_task_layer(
local_tls: (list[str]): list of task layers that are local to the current file
external_file (Path): external file to pull data into the current file from
"""
local_col = context.scene.asset_status.asset_collection
local_col = context.scene.asset_pipeline.asset_collection
if not local_col:
return "Unable to find Asset Collection"
col_base_name = local_col.name

View File

@ -17,20 +17,20 @@ class ASSETPIPE_OT_create_new_asset(bpy.types.Operator):
@classmethod
def poll(cls, context: bpy.types.Context) -> bool:
new_asset = context.scene.asset_new
if new_asset.name == "" or new_asset.dir == "":
asset_pipe = context.scene.asset_pipeline
if asset_pipe.name == "" or asset_pipe.dir == "":
cls.poll_message_set("Asset Name and Directory must be valid")
return False
if os.path.exists(os.path.join(new_asset.dir, new_asset.name)):
if os.path.exists(os.path.join(asset_pipe.dir, asset_pipe.name)):
cls.poll_message_set("Asset Folder already exists")
return False
return True
def execute(self, context: bpy.types.Context):
# New File is Createed so Props need to be saved
new_asset = context.scene.asset_new
self._name = new_asset.name
self._dir = new_asset.dir
asset_pipe = context.scene.asset_pipeline
self._name = asset_pipe.name
self._dir = asset_pipe.dir
# Create Asset Folder at Directory
asset_path = os.path.join(self._dir, self._name)
@ -53,7 +53,7 @@ class ASSETPIPE_OT_create_new_asset(bpy.types.Operator):
)
# Setup New File
asset_status = context.scene.asset_status
asset_status = context.scene.asset_pipeline
asset_status.is_asset_pipeline_file = True
bpy.data.collections.new(self._name)
asset_col = bpy.data.collections.get(self._name)
@ -108,11 +108,11 @@ class ASSETPIPE_OT_sync_with_publish(bpy.types.Operator):
)
def invoke(self, context: bpy.types.Context, event: bpy.types.Event):
self._temp_transfer_data = context.scene.temp_transfer_data_ownership
self._temp_transfer_data = context.scene.asset_pipeline.temp_transfer_data
self._temp_transfer_data.clear()
self._invalid_objs.clear()
local_col = context.scene.asset_status.asset_collection
local_col = context.scene.asset_pipeline.asset_collection
if not local_col:
self.report({'ERROR'}, "Top level collection could not be found")
return {'CANCELLED'}
@ -166,7 +166,7 @@ class ASSETPIPE_OT_sync_with_publish(bpy.types.Operator):
def execute(self, context: bpy.types.Context):
# Find current task Layer
temp_transfer_data = context.scene.temp_transfer_data_ownership
temp_transfer_data = context.scene.asset_pipeline.temp_transfer_data
core.ownership_set(temp_transfer_data)
current_file = Path(bpy.data.filepath)
task_layer_name = core.get_task_layer_name_from_file()
@ -207,7 +207,7 @@ class ASSETPIPE_OT_sync_with_publish(bpy.types.Operator):
bpy.ops.wm.open_mainfile(filepath=file_path)
# SKIP DEPRECIATED FILES
if context.scene.asset_status.is_depreciated:
if context.scene.asset_pipeline.is_depreciated:
continue
local_tls = [

View File

@ -6,36 +6,6 @@ avaliable task layers from the task_layer_defaults.json file that needs to be cr
"""
class AssetNew(bpy.types.PropertyGroup):
"""Properties needed to create new asset file/folders"""
dir: bpy.props.StringProperty(
name="Directory",
description="Target Path for new asset files",
subtype="DIR_PATH",
)
name: bpy.props.StringProperty(name="Name", description="Name for new Asset")
class AssetFileStatus(bpy.types.PropertyGroup):
"""Properties to manage the status of asset pipeline files"""
is_asset_pipeline_file: bpy.props.BoolProperty(
name="Asset Pipeline File",
description="Asset Pipeline Files are used in the asset pipeline, if file is not asset pipeline file user will be prompted to create a new asset",
default=False,
)
is_depreciated: bpy.props.BoolProperty(
name="Depreciated",
description="Depreciated files do not recieve any updates when syncing from a task layer",
default=False,
)
asset_collection: bpy.props.PointerProperty(type=bpy.types.Collection)
from . import constants
class AssetTransferData(bpy.types.PropertyGroup):
"""Properties to track transferable data on an object"""
@ -64,11 +34,37 @@ class AssetTransferDataTemp(bpy.types.PropertyGroup):
obj: bpy.props.PointerProperty(type=bpy.types.Object)
class AssetPipeline(bpy.types.PropertyGroup):
"""Properties to manage the status of asset pipeline files"""
is_asset_pipeline_file: bpy.props.BoolProperty(
name="Asset Pipeline File",
description="Asset Pipeline Files are used in the asset pipeline, if file is not asset pipeline file user will be prompted to create a new asset",
default=False,
)
is_depreciated: bpy.props.BoolProperty(
name="Depreciated",
description="Depreciated files do not recieve any updates when syncing from a task layer",
default=False,
)
asset_collection: bpy.props.PointerProperty(type=bpy.types.Collection)
temp_transfer_data: bpy.props.CollectionProperty(type=AssetTransferDataTemp)
## NEW FILE
dir: bpy.props.StringProperty(
name="Directory",
description="Target Path for new asset files",
subtype="DIR_PATH",
)
name: bpy.props.StringProperty(name="Name", description="Name for new Asset")
classes = (
AssetTransferData,
AssetFileStatus,
AssetTransferDataTemp,
AssetNew,
AssetPipeline,
)
@ -78,22 +74,16 @@ def register():
bpy.types.Object.transfer_data_ownership = bpy.props.CollectionProperty(
type=AssetTransferData
)
bpy.types.Scene.temp_transfer_data_ownership = bpy.props.CollectionProperty(
type=AssetTransferDataTemp
)
bpy.types.Scene.asset_status = bpy.props.PointerProperty(type=AssetFileStatus)
bpy.types.Scene.asset_pipeline = bpy.props.PointerProperty(type=AssetPipeline)
bpy.types.Object.asset_id_owner = bpy.props.EnumProperty(
name="ID Owner",
items=constants.TASK_LAYER_TYPES,
)
bpy.types.Scene.asset_new = bpy.props.PointerProperty(type=AssetNew)
def unregister():
for i in classes:
bpy.utils.unregister_class(i)
del bpy.types.Object.transfer_data_ownership
del bpy.types.Scene.temp_transfer_data_ownership
del bpy.types.Scene.asset_status
del bpy.types.Scene.asset_pipeline
del bpy.types.Object.asset_id_owner
del bpy.types.Scene.asset_new

View File

@ -12,18 +12,17 @@ class ASSETPIPE_sync(bpy.types.Panel):
def draw(self, context: bpy.types.Context) -> None:
layout = self.layout
status = context.scene.asset_status
if not status.is_asset_pipeline_file:
new_asset = context.scene.asset_new
layout.prop(new_asset, "dir")
layout.prop(new_asset, "name")
asset_pipe = context.scene.asset_pipeline
if not asset_pipe.is_asset_pipeline_file:
layout.prop(asset_pipe, "dir")
layout.prop(asset_pipe, "name")
layout.operator("assetpipe.create_new_asset")
# layout.operator("")
return
layout.label(
text=f"Active Task Layer: {context.collection.name.split('.')[-1]}"
)
layout.prop(status, "asset_collection", text="Asset")
layout.prop(asset_pipe, "asset_collection", text="Asset")
layout.label(text="Test UI")
layout.operator("assetpipe.publish_new_version")
layout.operator(
@ -45,8 +44,8 @@ class ASSETPIPE_ownership_inspector(bpy.types.Panel):
def draw(self, context: bpy.types.Context) -> None:
layout = self.layout
status = context.scene.asset_status
if not status.is_asset_pipeline_file:
asset_pipe = context.scene.asset_pipeline
if not asset_pipe.is_asset_pipeline_file:
layout.label(text="Open valid 'Asset Pipeline' file", icon="ERROR")
return
if not context.active_object:
@ -63,10 +62,10 @@ class ASSETPIPE_ownership_inspector(bpy.types.Panel):
task_layer_name = core.get_task_layer_name_from_file()
if task_layer_name not in constants.TASK_LAYER_KEYS:
status = context.scene.asset_status
asset_pipe = context.scene.asset_pipeline
box = layout.box()
box.label(text="Published File Settings")
box.prop(status, "is_depreciated")
box.prop(asset_pipe, "is_depreciated")
classes = (