Asset Pipeline v2 #145
@ -1,7 +1,7 @@
|
|||||||
import bpy
|
import bpy
|
||||||
from typing import Dict, Set
|
from typing import Dict, Set
|
||||||
|
|
||||||
from . import asset_suffix, constants, util
|
from . import asset_suffix, constants, util, core
|
||||||
from .transfer_data import transfer_core
|
from .transfer_data import transfer_core
|
||||||
|
|
||||||
|
|
||||||
@ -94,11 +94,12 @@ class AssetTransferMapping:
|
|||||||
coll_map: Dict[bpy.types.Collection, bpy.types.Collection] = {}
|
coll_map: Dict[bpy.types.Collection, bpy.types.Collection] = {}
|
||||||
|
|
||||||
local_tl_names = [
|
local_tl_names = [
|
||||||
tl_type[1]
|
core.get_name_with_asset_prefix(tl_type[1])
|
||||||
for tl_type in constants.TASK_LAYER_TYPES
|
for tl_type in constants.TASK_LAYER_TYPES
|
||||||
if tl_type[0] in self._local_tls
|
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:
|
for local_task_layer_col in self._local_col.children:
|
||||||
if (
|
if (
|
||||||
asset_suffix.get_basename(local_task_layer_col.name)
|
asset_suffix.get_basename(local_task_layer_col.name)
|
||||||
|
@ -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
|
list[bpy.types.Object]: Returns a list of objects that have no owner and will not be included
|
||||||
in the merge process
|
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)
|
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)
|
task_layer_col = local_col.children.get(task_layer_col_name)
|
||||||
for obj in local_col.all_objects:
|
for obj in local_col.all_objects:
|
||||||
# Mark Asset ID Owner for objects in the current task layers collection
|
# 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):
|
if obj.asset_id_owner == "NONE" and obj in list(task_layer_col.all_objects):
|
||||||
obj.asset_id_owner = task_layer_key
|
obj.asset_id_owner = task_layer_key
|
||||||
|
obj.name = get_name_with_asset_prefix(obj.name)
|
||||||
# Skip items that have no owner
|
# Skip items that have no owner
|
||||||
if obj.asset_id_owner == "NONE":
|
if obj.asset_id_owner == "NONE":
|
||||||
continue
|
continue
|
||||||
@ -101,10 +103,15 @@ def get_invalid_objects(
|
|||||||
|
|
||||||
def get_task_layer_col_name(task_layer_key):
|
def get_task_layer_col_name(task_layer_key):
|
||||||
# TODO Docstring and return types
|
# 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]
|
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 ""
|
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:
|
def remap_user(source_datablock: bpy.data, target_datablock: bpy.data) -> None:
|
||||||
|
@ -14,6 +14,7 @@ class ASSETPIPE_OT_create_new_asset(bpy.types.Operator):
|
|||||||
|
|
||||||
_name = None
|
_name = None
|
||||||
_dir = None
|
_dir = None
|
||||||
|
_prefix = None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context: bpy.types.Context) -> bool:
|
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
|
asset_pipe = context.scene.asset_pipeline
|
||||||
self._name = asset_pipe.name
|
self._name = asset_pipe.name
|
||||||
self._dir = asset_pipe.dir
|
self._dir = asset_pipe.dir
|
||||||
|
self._prefix = asset_pipe.prefix
|
||||||
|
|
||||||
# Create Asset Folder at Directory
|
# Create Asset Folder at Directory
|
||||||
asset_path = os.path.join(self._dir, self._name)
|
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
|
# Setup New File
|
||||||
asset_status = context.scene.asset_pipeline
|
asset_pipe = context.scene.asset_pipeline
|
||||||
asset_status.is_asset_pipeline_file = True
|
asset_pipe.is_asset_pipeline_file = True
|
||||||
bpy.data.collections.new(self._name)
|
bpy.data.collections.new(self._name)
|
||||||
asset_col = bpy.data.collections.get(self._name)
|
asset_col = bpy.data.collections.get(self._name)
|
||||||
context.scene.collection.children.link(asset_col)
|
context.scene.collection.children.link(asset_col)
|
||||||
asset_status.asset_collection = asset_col
|
asset_pipe.asset_collection = asset_col
|
||||||
asset_pipe = context.scene.asset_pipeline
|
asset_pipe.name = self._name
|
||||||
|
asset_pipe.prefix = self._prefix
|
||||||
|
|
||||||
for task_layer_name in constants.TASK_LAYER_NAMES:
|
for task_layer_key in constants.TASK_LAYER_KEYS:
|
||||||
if task_layer_name == "None":
|
if task_layer_key == "NONE":
|
||||||
continue
|
continue
|
||||||
bpy.data.collections.new(task_layer_name)
|
col_name = core.get_task_layer_col_name(task_layer_key)
|
||||||
asset_col.children.link(bpy.data.collections.get(task_layer_name))
|
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):
|
for task_layer_key in reversed(constants.TASK_LAYER_KEYS):
|
||||||
if task_layer_key == "NONE":
|
if task_layer_key == "NONE":
|
||||||
|
@ -73,6 +73,10 @@ class AssetPipeline(bpy.types.PropertyGroup):
|
|||||||
)
|
)
|
||||||
name: bpy.props.StringProperty(name="Name", description="Name for new Asset")
|
name: bpy.props.StringProperty(name="Name", description="Name for new Asset")
|
||||||
|
|
||||||
|
prefix: bpy.props.StringProperty(
|
||||||
|
name="Prefix", description="Prefix for new Asset", default=""
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
AssetTransferData,
|
AssetTransferData,
|
||||||
|
@ -16,6 +16,7 @@ class ASSETPIPE_sync(bpy.types.Panel):
|
|||||||
if not asset_pipe.is_asset_pipeline_file:
|
if not asset_pipe.is_asset_pipeline_file:
|
||||||
layout.prop(asset_pipe, "dir")
|
layout.prop(asset_pipe, "dir")
|
||||||
layout.prop(asset_pipe, "name")
|
layout.prop(asset_pipe, "name")
|
||||||
|
layout.prop(asset_pipe, "prefix")
|
||||||
layout.operator("assetpipe.create_new_asset")
|
layout.operator("assetpipe.create_new_asset")
|
||||||
# layout.operator("")
|
# layout.operator("")
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user