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 31 additions and 14 deletions
Showing only changes of commit 06bf5de454 - Show all commits

View File

@ -1,7 +1,7 @@
import bpy
from typing import Dict, Set
from . import asset_suffix, constants, util
from . import asset_suffix, constants, util, core
from .transfer_data import transfer_core
@ -94,11 +94,12 @@ class AssetTransferMapping:
coll_map: Dict[bpy.types.Collection, bpy.types.Collection] = {}
local_tl_names = [
tl_type[1]
core.get_name_with_asset_prefix(tl_type[1])
for tl_type in constants.TASK_LAYER_TYPES
if tl_type[0] in self._local_tls
]
# TODO Include PREFIX checker in this stupidity
for local_task_layer_col in self._local_col.children:
if (
asset_suffix.get_basename(local_task_layer_col.name)

View File

@ -47,14 +47,16 @@ def ownership_get(
list[bpy.types.Object]: Returns a list of objects that have no owner and will not be included
in the merge process
"""
task_layer_key = scene.asset_pipeline.task_layer_name
asset_pipe = scene.asset_pipeline
asset_pipe.temp_transfer_data.clear()
task_layer_key = asset_pipe.task_layer_name
task_layer_col_name = get_task_layer_col_name(task_layer_key)
scene.asset_pipeline.temp_transfer_data.clear()
task_layer_col = local_col.children.get(task_layer_col_name)
for obj in local_col.all_objects:
# Mark Asset ID Owner for objects in the current task layers collection
if obj.asset_id_owner == "NONE" and obj in list(task_layer_col.all_objects):
obj.asset_id_owner = task_layer_key
obj.name = get_name_with_asset_prefix(obj.name)
# Skip items that have no owner
if obj.asset_id_owner == "NONE":
continue
@ -101,10 +103,15 @@ def get_invalid_objects(
def get_task_layer_col_name(task_layer_key):
# TODO Docstring and return types
asset_pipe = bpy.context.scene.asset_pipeline
task_layer_name = get_dict_tuple_item(constants.TASK_LAYER_TYPES, task_layer_key)[1]
return get_name_with_asset_prefix(task_layer_name)
def get_name_with_asset_prefix(name):
# TODO Docstring and return types
asset_pipe = bpy.context.scene.asset_pipeline
prefix = asset_pipe.prefix + "." if asset_pipe.prefix != "" else ""
return prefix + task_layer_name
return prefix + name
def remap_user(source_datablock: bpy.data, target_datablock: bpy.data) -> None:

View File

@ -14,6 +14,7 @@ class ASSETPIPE_OT_create_new_asset(bpy.types.Operator):
_name = None
_dir = None
_prefix = None
@classmethod
def poll(cls, context: bpy.types.Context) -> bool:
@ -31,6 +32,7 @@ class ASSETPIPE_OT_create_new_asset(bpy.types.Operator):
asset_pipe = context.scene.asset_pipeline
self._name = asset_pipe.name
self._dir = asset_pipe.dir
self._prefix = asset_pipe.prefix
# Create Asset Folder at Directory
asset_path = os.path.join(self._dir, self._name)
@ -53,19 +55,21 @@ class ASSETPIPE_OT_create_new_asset(bpy.types.Operator):
)
# Setup New File
asset_status = context.scene.asset_pipeline
asset_status.is_asset_pipeline_file = True
asset_pipe = context.scene.asset_pipeline
asset_pipe.is_asset_pipeline_file = True
bpy.data.collections.new(self._name)
asset_col = bpy.data.collections.get(self._name)
context.scene.collection.children.link(asset_col)
asset_status.asset_collection = asset_col
asset_pipe = context.scene.asset_pipeline
asset_pipe.asset_collection = asset_col
asset_pipe.name = self._name
asset_pipe.prefix = self._prefix
for task_layer_name in constants.TASK_LAYER_NAMES:
if task_layer_name == "None":
for task_layer_key in constants.TASK_LAYER_KEYS:
if task_layer_key == "NONE":
continue
bpy.data.collections.new(task_layer_name)
asset_col.children.link(bpy.data.collections.get(task_layer_name))
col_name = core.get_task_layer_col_name(task_layer_key)
bpy.data.collections.new(col_name)
asset_col.children.link(bpy.data.collections.get(col_name))
for task_layer_key in reversed(constants.TASK_LAYER_KEYS):
if task_layer_key == "NONE":

View File

@ -73,6 +73,10 @@ class AssetPipeline(bpy.types.PropertyGroup):
)
name: bpy.props.StringProperty(name="Name", description="Name for new Asset")
prefix: bpy.props.StringProperty(
name="Prefix", description="Prefix for new Asset", default=""
)
classes = (
AssetTransferData,

View File

@ -16,6 +16,7 @@ class ASSETPIPE_sync(bpy.types.Panel):
if not asset_pipe.is_asset_pipeline_file:
layout.prop(asset_pipe, "dir")
layout.prop(asset_pipe, "name")
layout.prop(asset_pipe, "prefix")
layout.operator("assetpipe.create_new_asset")
# layout.operator("")
return