Asset Pipeline v2 #145
12
scripts-blender/addons/asset_pipeline_2/images.py
Normal file
12
scripts-blender/addons/asset_pipeline_2/images.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import bpy
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
def save_images():
|
||||||
|
# TODO Make customizable
|
||||||
|
save_path = Path(bpy.data.filepath).parent.joinpath("images")
|
||||||
|
for img in bpy.data.images:
|
||||||
|
if img.is_dirty:
|
||||||
|
filepath = save_path.joinpath(img.name).__str__()
|
||||||
|
img.filepath = filepath
|
||||||
|
img.save(filepath=filepath)
|
@ -8,6 +8,7 @@ from .merge.publish import (
|
|||||||
from .merge.naming import get_task_layer_col_name
|
from .merge.naming import get_task_layer_col_name
|
||||||
|
|
||||||
from .merge.transfer_data.transfer_ui import draw_transfer_data
|
from .merge.transfer_data.transfer_ui import draw_transfer_data
|
||||||
|
from .images import save_images
|
||||||
from . import constants
|
from . import constants
|
||||||
from .sync import (
|
from .sync import (
|
||||||
sync_poll,
|
sync_poll,
|
||||||
@ -157,25 +158,24 @@ class ASSETPIPE_OT_sync_pull(bpy.types.Operator):
|
|||||||
default=False,
|
default=False,
|
||||||
description="Show New Transfer Data",
|
description="Show New Transfer Data",
|
||||||
)
|
)
|
||||||
|
save: bpy.props.BoolProperty(
|
||||||
@classmethod
|
name="Save File & Images",
|
||||||
def poll(cls, context: bpy.types.Context) -> bool:
|
default=True,
|
||||||
if any([img.is_dirty for img in bpy.data.images]):
|
description="Save Current File and Images before Push",
|
||||||
cls.poll_message_set("Please save unsaved Images")
|
)
|
||||||
return False
|
|
||||||
if bpy.data.is_dirty:
|
|
||||||
cls.poll_message_set("Please save current .blend file")
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
def invoke(self, context: bpy.types.Context, event: bpy.types.Event):
|
def invoke(self, context: bpy.types.Context, event: bpy.types.Event):
|
||||||
sync_invoke(self, context)
|
sync_invoke(self, context)
|
||||||
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):
|
||||||
|
self.layout.prop(self, "save")
|
||||||
sync_draw(self, context)
|
sync_draw(self, context)
|
||||||
|
|
||||||
def execute(self, context: bpy.types.Context):
|
def execute(self, context: bpy.types.Context):
|
||||||
|
if self.save:
|
||||||
|
save_images()
|
||||||
|
bpy.ops.wm.save_mainfile()
|
||||||
# Find current task Layer
|
# Find current task Layer
|
||||||
sync_execute_update_ownership(self, context)
|
sync_execute_update_ownership(self, context)
|
||||||
sync_execute_prepare_sync(self, context)
|
sync_execute_prepare_sync(self, context)
|
||||||
@ -207,15 +207,11 @@ class ASSETPIPE_OT_sync_push(bpy.types.Operator):
|
|||||||
description="Pull in any new data from the Published file before Pushing",
|
description="Pull in any new data from the Published file before Pushing",
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
save: bpy.props.BoolProperty(
|
||||||
def poll(cls, context: bpy.types.Context) -> bool:
|
name="Save File & Images",
|
||||||
if any([img.is_dirty for img in bpy.data.images]):
|
default=True,
|
||||||
cls.poll_message_set("Please save unsaved Images")
|
description="Save Current File and Images before Push",
|
||||||
return False
|
)
|
||||||
if bpy.data.is_dirty:
|
|
||||||
cls.poll_message_set("Please save current .blend file")
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
def invoke(self, context: bpy.types.Context, event: bpy.types.Event):
|
def invoke(self, context: bpy.types.Context, event: bpy.types.Event):
|
||||||
sync_invoke(self, context)
|
sync_invoke(self, context)
|
||||||
@ -223,9 +219,14 @@ class ASSETPIPE_OT_sync_push(bpy.types.Operator):
|
|||||||
|
|
||||||
def draw(self, context: bpy.types.Context):
|
def draw(self, context: bpy.types.Context):
|
||||||
self.layout.prop(self, "pull")
|
self.layout.prop(self, "pull")
|
||||||
|
self.layout.prop(self, "save")
|
||||||
sync_draw(self, context)
|
sync_draw(self, context)
|
||||||
|
|
||||||
def execute(self, context: bpy.types.Context):
|
def execute(self, context: bpy.types.Context):
|
||||||
|
if self.save:
|
||||||
|
save_images()
|
||||||
|
bpy.ops.wm.save_mainfile()
|
||||||
|
|
||||||
# Find current task Layer
|
# Find current task Layer
|
||||||
sync_execute_update_ownership(self, context)
|
sync_execute_update_ownership(self, context)
|
||||||
sync_execute_prepare_sync(self, context)
|
sync_execute_prepare_sync(self, context)
|
||||||
|
Loading…
Reference in New Issue
Block a user