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 37 additions and 18 deletions
Showing only changes of commit 6daada483f - Show all commits

View File

@ -24,18 +24,18 @@ MATERIAL_SLOT_KEY = TRANSFER_DATA_KEYS[3]
PUBLISH_TYPES = [
(
"ACTIVE",
"publish",
"Active",
"Publish a new active version that will become the latest published version",
),
(
"STAGE",
"staged",
"Staged",
"""Publish a staged version that will replace the last active version as the Push/Pull target.
Used for internal asset pipeline use only""",
),
(
"REVIEW",
"review",
"Review",
"Test the results that will be published in the review area, will not be used as Push/Pull target",
),

View File

@ -96,28 +96,40 @@ def merge_task_layer(
asset_suffix.remove_suffix_from_hierarchy(local_col)
def find_published_file_version(file):
def find_file_version(file):
return int(file.name.split(".")[1].replace("v", ""))
def get_next_published_file(current_file: Path):
last_publish = find_published_file(current_file)
new_version_number = find_published_file_version(last_publish) + 1
def get_next_published_file(current_file: Path, publish_type="publish"):
last_publish = find_published(current_file, publish_type)
base_name = current_file.name.split(".")[0]
publish_dir = current_file.parent.joinpath(publish_type)
if not last_publish:
new_version_number = 1
else:
new_version_number = find_file_version(last_publish) + 1
new_version = "{0:0=3d}".format(new_version_number)
return last_publish.parent.joinpath(
last_publish.name.split(".v")[0] + f".v" + new_version + ".blend"
)
return publish_dir.joinpath(base_name + f".v" + new_version + ".blend")
def find_published_file(current_file: Path):
publish_dir = current_file.parent.joinpath("publish")
def find_published(current_file: Path, publish_type="publish"):
publish_dir = current_file.parent.joinpath(publish_type)
if not publish_dir.exists():
return
published_files = list(current_file.parent.joinpath("publish").glob('*.blend'))
published_files.sort(key=find_published_file_version)
published_files = list(publish_dir.glob('*.blend'))
published_files.sort(key=find_file_version)
if published_files:
return published_files[-1]
def find_sync_target(current_file: Path):
latest_staged = find_published(current_file, publish_type="staged")
if latest_staged:
return latest_staged
return find_published(current_file, publish_type="publish")
def import_data_from_lib(
libpath: Path,
data_category: str,

View File

@ -95,7 +95,7 @@ class ASSETPIPE_OT_sync_with_publish(bpy.types.Operator):
self.report({'ERROR'}, "Current File Name doesn't contain valid task layer")
return {'CANCELLED'}
pub_file = core.find_published_file(current_file)
pub_file = core.find_sync_target(current_file)
pub_file_path = pub_file.__str__()
if self.pull:
@ -144,12 +144,19 @@ class ASSETPIPE_OT_publish_new_version(bpy.types.Operator):
bl_description = """Create a new Published Version in the Publish Area"""
publish_types: bpy.props.EnumProperty(
name="Transfer Data Owner",
name="Type",
items=constants.PUBLISH_TYPES,
)
# TODO use published types to publish to different folders
def invoke(self, context: bpy.types.Context, event: bpy.types.Event):
return context.window_manager.invoke_props_dialog(self, width=400)
def draw(self, context: bpy.types.Context):
layout = self.layout
layout.prop(self, "publish_types")
def execute(self, context: bpy.types.Context):
if bpy.data.is_dirty:
self.report(
@ -158,7 +165,7 @@ class ASSETPIPE_OT_publish_new_version(bpy.types.Operator):
)
return {'CANCELLED'}
current_file = Path(bpy.data.filepath)
new_file_path = core.get_next_published_file(current_file)
new_file_path = core.get_next_published_file(current_file, self.publish_types)
bpy.ops.wm.save_as_mainfile(filepath=new_file_path.__str__(), copy=True)
return {'FINISHED'}