Asset Pipeline v2 #145
@ -127,7 +127,7 @@ class AssetTransferMapping:
|
|||||||
|
|
||||||
def _gen_transfer_data_map(self):
|
def _gen_transfer_data_map(self):
|
||||||
transfer_data_map: Dict[bpy.types.Collection, bpy.types.Collection] = {}
|
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:
|
for source_obj in self.object_map:
|
||||||
target_obj = self.object_map[source_obj]
|
target_obj = self.object_map[source_obj]
|
||||||
objs = [source_obj, target_obj]
|
objs = [source_obj, target_obj]
|
||||||
|
@ -114,7 +114,7 @@ def merge_task_layer(
|
|||||||
local_tls: (list[str]): list of task layers that are local to the current file
|
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
|
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:
|
if not local_col:
|
||||||
return "Unable to find Asset Collection"
|
return "Unable to find Asset Collection"
|
||||||
col_base_name = local_col.name
|
col_base_name = local_col.name
|
||||||
|
@ -17,20 +17,20 @@ class ASSETPIPE_OT_create_new_asset(bpy.types.Operator):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context: bpy.types.Context) -> bool:
|
def poll(cls, context: bpy.types.Context) -> bool:
|
||||||
new_asset = context.scene.asset_new
|
asset_pipe = context.scene.asset_pipeline
|
||||||
if new_asset.name == "" or new_asset.dir == "":
|
if asset_pipe.name == "" or asset_pipe.dir == "":
|
||||||
cls.poll_message_set("Asset Name and Directory must be valid")
|
cls.poll_message_set("Asset Name and Directory must be valid")
|
||||||
return False
|
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")
|
cls.poll_message_set("Asset Folder already exists")
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def execute(self, context: bpy.types.Context):
|
def execute(self, context: bpy.types.Context):
|
||||||
# New File is Createed so Props need to be saved
|
# New File is Createed so Props need to be saved
|
||||||
new_asset = context.scene.asset_new
|
asset_pipe = context.scene.asset_pipeline
|
||||||
self._name = new_asset.name
|
self._name = asset_pipe.name
|
||||||
self._dir = new_asset.dir
|
self._dir = asset_pipe.dir
|
||||||
|
|
||||||
# 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,7 +53,7 @@ class ASSETPIPE_OT_create_new_asset(bpy.types.Operator):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Setup New File
|
# Setup New File
|
||||||
asset_status = context.scene.asset_status
|
asset_status = context.scene.asset_pipeline
|
||||||
asset_status.is_asset_pipeline_file = True
|
asset_status.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)
|
||||||
@ -108,11 +108,11 @@ class ASSETPIPE_OT_sync_with_publish(bpy.types.Operator):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def invoke(self, context: bpy.types.Context, event: bpy.types.Event):
|
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._temp_transfer_data.clear()
|
||||||
self._invalid_objs.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:
|
if not local_col:
|
||||||
self.report({'ERROR'}, "Top level collection could not be found")
|
self.report({'ERROR'}, "Top level collection could not be found")
|
||||||
return {'CANCELLED'}
|
return {'CANCELLED'}
|
||||||
@ -166,7 +166,7 @@ class ASSETPIPE_OT_sync_with_publish(bpy.types.Operator):
|
|||||||
|
|
||||||
def execute(self, context: bpy.types.Context):
|
def execute(self, context: bpy.types.Context):
|
||||||
# Find current task Layer
|
# 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)
|
core.ownership_set(temp_transfer_data)
|
||||||
current_file = Path(bpy.data.filepath)
|
current_file = Path(bpy.data.filepath)
|
||||||
task_layer_name = core.get_task_layer_name_from_file()
|
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)
|
bpy.ops.wm.open_mainfile(filepath=file_path)
|
||||||
|
|
||||||
# SKIP DEPRECIATED FILES
|
# SKIP DEPRECIATED FILES
|
||||||
if context.scene.asset_status.is_depreciated:
|
if context.scene.asset_pipeline.is_depreciated:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
local_tls = [
|
local_tls = [
|
||||||
|
@ -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):
|
class AssetTransferData(bpy.types.PropertyGroup):
|
||||||
"""Properties to track transferable data on an object"""
|
"""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)
|
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 = (
|
classes = (
|
||||||
AssetTransferData,
|
AssetTransferData,
|
||||||
AssetFileStatus,
|
|
||||||
AssetTransferDataTemp,
|
AssetTransferDataTemp,
|
||||||
AssetNew,
|
AssetPipeline,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -78,22 +74,16 @@ def register():
|
|||||||
bpy.types.Object.transfer_data_ownership = bpy.props.CollectionProperty(
|
bpy.types.Object.transfer_data_ownership = bpy.props.CollectionProperty(
|
||||||
type=AssetTransferData
|
type=AssetTransferData
|
||||||
)
|
)
|
||||||
bpy.types.Scene.temp_transfer_data_ownership = bpy.props.CollectionProperty(
|
bpy.types.Scene.asset_pipeline = bpy.props.PointerProperty(type=AssetPipeline)
|
||||||
type=AssetTransferDataTemp
|
|
||||||
)
|
|
||||||
bpy.types.Scene.asset_status = bpy.props.PointerProperty(type=AssetFileStatus)
|
|
||||||
bpy.types.Object.asset_id_owner = bpy.props.EnumProperty(
|
bpy.types.Object.asset_id_owner = bpy.props.EnumProperty(
|
||||||
name="ID Owner",
|
name="ID Owner",
|
||||||
items=constants.TASK_LAYER_TYPES,
|
items=constants.TASK_LAYER_TYPES,
|
||||||
)
|
)
|
||||||
bpy.types.Scene.asset_new = bpy.props.PointerProperty(type=AssetNew)
|
|
||||||
|
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
for i in classes:
|
for i in classes:
|
||||||
bpy.utils.unregister_class(i)
|
bpy.utils.unregister_class(i)
|
||||||
del bpy.types.Object.transfer_data_ownership
|
del bpy.types.Object.transfer_data_ownership
|
||||||
del bpy.types.Scene.temp_transfer_data_ownership
|
del bpy.types.Scene.asset_pipeline
|
||||||
del bpy.types.Scene.asset_status
|
|
||||||
del bpy.types.Object.asset_id_owner
|
del bpy.types.Object.asset_id_owner
|
||||||
del bpy.types.Scene.asset_new
|
|
||||||
|
@ -12,18 +12,17 @@ class ASSETPIPE_sync(bpy.types.Panel):
|
|||||||
|
|
||||||
def draw(self, context: bpy.types.Context) -> None:
|
def draw(self, context: bpy.types.Context) -> None:
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
status = context.scene.asset_status
|
asset_pipe = context.scene.asset_pipeline
|
||||||
if not status.is_asset_pipeline_file:
|
if not asset_pipe.is_asset_pipeline_file:
|
||||||
new_asset = context.scene.asset_new
|
layout.prop(asset_pipe, "dir")
|
||||||
layout.prop(new_asset, "dir")
|
layout.prop(asset_pipe, "name")
|
||||||
layout.prop(new_asset, "name")
|
|
||||||
layout.operator("assetpipe.create_new_asset")
|
layout.operator("assetpipe.create_new_asset")
|
||||||
# layout.operator("")
|
# layout.operator("")
|
||||||
return
|
return
|
||||||
layout.label(
|
layout.label(
|
||||||
text=f"Active Task Layer: {context.collection.name.split('.')[-1]}"
|
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.label(text="Test UI")
|
||||||
layout.operator("assetpipe.publish_new_version")
|
layout.operator("assetpipe.publish_new_version")
|
||||||
layout.operator(
|
layout.operator(
|
||||||
@ -45,8 +44,8 @@ class ASSETPIPE_ownership_inspector(bpy.types.Panel):
|
|||||||
|
|
||||||
def draw(self, context: bpy.types.Context) -> None:
|
def draw(self, context: bpy.types.Context) -> None:
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
status = context.scene.asset_status
|
asset_pipe = context.scene.asset_pipeline
|
||||||
if not status.is_asset_pipeline_file:
|
if not asset_pipe.is_asset_pipeline_file:
|
||||||
layout.label(text="Open valid 'Asset Pipeline' file", icon="ERROR")
|
layout.label(text="Open valid 'Asset Pipeline' file", icon="ERROR")
|
||||||
return
|
return
|
||||||
if not context.active_object:
|
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()
|
task_layer_name = core.get_task_layer_name_from_file()
|
||||||
if task_layer_name not in constants.TASK_LAYER_KEYS:
|
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 = layout.box()
|
||||||
box.label(text="Published File Settings")
|
box.label(text="Published File Settings")
|
||||||
box.prop(status, "is_depreciated")
|
box.prop(asset_pipe, "is_depreciated")
|
||||||
|
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
|
Loading…
Reference in New Issue
Block a user