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.
3 changed files with 30 additions and 23 deletions
Showing only changes of commit dba57f62d0 - Show all commits

View File

@ -3,8 +3,8 @@ from .. import constants
def get_local_task_layers(): def get_local_task_layers():
local_task_layer_strings = bpy.context.scene.asset_pipeline.local_task_layers local_task_layers = bpy.context.scene.asset_pipeline.local_task_layers
return [string for string in local_task_layer_strings.split(",") if string != ""] return [task_layer.name for task_layer in local_task_layers]
def get_default_task_layer(td_type: str, name=""): def get_default_task_layer(td_type: str, name=""):

View File

@ -48,22 +48,21 @@ class ASSETPIPE_OT_create_new_asset(bpy.types.Operator):
def invoke(self, context: bpy.types.Context, event): def invoke(self, context: bpy.types.Context, event):
# Dynamically Create Task Layer Bools # Dynamically Create Task Layer Bools
task_layer_settings = context.scene.asset_pipeline.task_layer_settings all_task_layers = context.scene.asset_pipeline.all_task_layers
task_layer_settings.clear() all_task_layers.clear()
for task_layer_key in constants.TASK_LAYER_TYPES.keys(): for task_layer_key in constants.TASK_LAYER_TYPES.keys():
if task_layer_key == "NONE": if task_layer_key == "NONE":
continue continue
transfer_data_item = task_layer_settings.add() new_task_layer = all_task_layers.add()
transfer_data_item.name = constants.TASK_LAYER_TYPES[task_layer_key] new_task_layer.name = task_layer_key
transfer_data_item.key = task_layer_key
return context.window_manager.invoke_props_dialog(self, width=400) return context.window_manager.invoke_props_dialog(self, width=400)
def draw(self, context: bpy.types.Context): def draw(self, context: bpy.types.Context):
box = self.layout.box() box = self.layout.box()
task_layer_settings = context.scene.asset_pipeline.task_layer_settings all_task_layers = context.scene.asset_pipeline.all_task_layers
box.label(text="Choose Which Task Layers will be local the current file") box.label(text="Choose Which Task Layers will be local the current file")
for task_layer_bool in task_layer_settings: for task_layer_bool in all_task_layers:
box.prop(task_layer_bool, "is_local", text=task_layer_bool.name) box.prop(task_layer_bool, "is_local", text=task_layer_bool.name)
self.layout.prop(self, "create_files") self.layout.prop(self, "create_files")
@ -74,13 +73,13 @@ class ASSETPIPE_OT_create_new_asset(bpy.types.Operator):
self._dir = bpy.path.abspath(asset_pipe.dir) self._dir = bpy.path.abspath(asset_pipe.dir)
self._prefix = asset_pipe.prefix self._prefix = asset_pipe.prefix
task_layer_settings = context.scene.asset_pipeline.task_layer_settings all_task_layers = context.scene.asset_pipeline.all_task_layers
local_tls = [] local_tls = []
for task_layer_bool in task_layer_settings: for task_layer_bool in all_task_layers:
if task_layer_bool.is_local: if task_layer_bool.is_local:
local_tls.append(task_layer_bool.key) local_tls.append(task_layer_bool.name)
if not any(task_layer_bool.is_local for task_layer_bool in task_layer_settings): if not any(task_layer_bool.is_local for task_layer_bool in all_task_layers):
self.report( self.report(
{'ERROR'}, {'ERROR'},
"Please select at least one task layer to be local to the current file", "Please select at least one task layer to be local to the current file",
@ -93,7 +92,8 @@ class ASSETPIPE_OT_create_new_asset(bpy.types.Operator):
for publish_type in constants.PUBLISH_KEYS: for publish_type in constants.PUBLISH_KEYS:
os.mkdir(os.path.join(asset_path, publish_type)) os.mkdir(os.path.join(asset_path, publish_type))
# Setup New File
# Setup Base File
asset_pipe = context.scene.asset_pipeline asset_pipe = context.scene.asset_pipeline
asset_pipe.is_asset_pipeline_file = True asset_pipe.is_asset_pipeline_file = True
bpy.data.collections.new(self._name) bpy.data.collections.new(self._name)
@ -104,11 +104,16 @@ class ASSETPIPE_OT_create_new_asset(bpy.types.Operator):
asset_pipe.prefix = self._prefix asset_pipe.prefix = self._prefix
starting_file = "" starting_file = ""
local_tls_string = ""
for task_layer in local_tls:
local_tls_string += task_layer + ","
asset_pipe.local_task_layers = local_tls_string
first_file = os.path.join(asset_path, Path(bpy.data.filepath).name) first_file = os.path.join(asset_path, Path(bpy.data.filepath).name)
local_task_layers = context.scene.asset_pipeline.local_task_layers
# Update Local Task Layers for New File
local_task_layers.clear()
for task_layer in all_task_layers:
if task_layer.is_local == True:
new_local_task_layer = local_task_layers.add()
new_local_task_layer.name = task_layer.name
bpy.ops.wm.save_as_mainfile(filepath=first_file, copy=True) bpy.ops.wm.save_as_mainfile(filepath=first_file, copy=True)
starting_file = first_file starting_file = first_file
@ -121,8 +126,6 @@ class ASSETPIPE_OT_create_new_asset(bpy.types.Operator):
self._name + "." + constants.TASK_LAYER_TYPES[task_layer_key] + ".blend" self._name + "." + constants.TASK_LAYER_TYPES[task_layer_key] + ".blend"
) )
asset_pipe.local_task_layers = task_layer_key + ","
# Remove Data From Newly Created Files that aren't the user's main file # Remove Data From Newly Created Files that aren't the user's main file
for col in bpy.data.collections: for col in bpy.data.collections:
if not col == asset_col: if not col == asset_col:
@ -134,8 +137,11 @@ class ASSETPIPE_OT_create_new_asset(bpy.types.Operator):
do_local_ids=True, do_linked_ids=False, do_recursive=True do_local_ids=True, do_linked_ids=False, do_recursive=True
) )
local_task_layers.clear()
new_local_task_layer = local_task_layers.add()
new_local_task_layer.name = task_layer_key
task_layer_file = os.path.join(asset_path, name) task_layer_file = os.path.join(asset_path, name)
asset_pipe.local_task_layers = task_layer_key + ","
bpy.ops.wm.save_as_mainfile(filepath=task_layer_file, copy=True) bpy.ops.wm.save_as_mainfile(filepath=task_layer_file, copy=True)
# Create intial publish based on task layers. # Create intial publish based on task layers.

View File

@ -1,5 +1,6 @@
import bpy import bpy
from . import constants from . import constants
from .merge.task_layer import get_local_task_layers
""" NOTE Items in these properties groups should be generated by a function that finds the """ NOTE Items in these properties groups should be generated by a function that finds the
avaliable task layers from the task_layer_defaults.json file that needs to be created. avaliable task layers from the task_layer_defaults.json file that needs to be created.
@ -36,7 +37,6 @@ class AssetTransferDataTemp(bpy.types.PropertyGroup):
class TaskLayerSettings(bpy.types.PropertyGroup): class TaskLayerSettings(bpy.types.PropertyGroup):
is_local: bpy.props.BoolProperty(name="Task Layer is Local", default=False) is_local: bpy.props.BoolProperty(name="Task Layer is Local", default=False)
key: bpy.props.StringProperty(name="Key for Task Layer", default="")
class AssetPipeline(bpy.types.PropertyGroup): class AssetPipeline(bpy.types.PropertyGroup):
@ -79,7 +79,8 @@ class AssetPipeline(bpy.types.PropertyGroup):
name="Prefix", description="Prefix for new Asset", default="" name="Prefix", description="Prefix for new Asset", default=""
) )
task_layer_settings: bpy.props.CollectionProperty(type=TaskLayerSettings) all_task_layers: bpy.props.CollectionProperty(type=TaskLayerSettings)
local_task_layers: bpy.props.CollectionProperty(type=TaskLayerSettings)
classes = ( classes = (