New Tool: Collect images.
This commit is contained in:
parent
b862e95e6a
commit
7aef9abb9d
|
@ -291,6 +291,7 @@ class OscPanelFiles(Panel):
|
|||
col = layout.column(align=1)
|
||||
col.operator("file.save_incremental_osc", icon="NEW")
|
||||
col.operator("image.reload_images_osc", icon="IMAGE_COL")
|
||||
col.operator("file.collect_all_images", icon="IMAGE_COL")
|
||||
col.operator("file.sync_missing_groups", icon="LINK_AREA")
|
||||
col = layout.column(align=1)
|
||||
colrow = col.row(align=1)
|
||||
|
|
|
@ -21,13 +21,14 @@
|
|||
import bpy
|
||||
from bpy.types import Operator
|
||||
import os
|
||||
import shutil
|
||||
|
||||
|
||||
# ---------------------------RELOAD IMAGES------------------
|
||||
|
||||
|
||||
class reloadImages (Operator):
|
||||
"""Reloads all bitmaps in the scene"""
|
||||
"""Reloads all bitmaps in the scene."""
|
||||
bl_idname = "image.reload_images_osc"
|
||||
bl_label = "Reload Images"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
@ -41,7 +42,7 @@ class reloadImages (Operator):
|
|||
# ------------------------ SAVE INCREMENTAL ------------------------
|
||||
|
||||
class saveIncremental(Operator):
|
||||
"""Saves incremental version of the blend file Ex: '_v01' '_v02'"""
|
||||
"""Saves incremental version of the blend file Ex: “_v01” "_v02"."""
|
||||
bl_idname = "file.save_incremental_osc"
|
||||
bl_label = "Save Incremental File"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
@ -72,8 +73,7 @@ bpy.types.Scene.oscReplaceText = bpy.props.StringProperty(
|
|||
|
||||
|
||||
class replaceFilePath(Operator):
|
||||
"""Replace the paths set on the “search test” field by the ones in “replace” field. """ \
|
||||
"""'_v01' »» '_v02' /folder1/render_v01.png »» /folder1/render_v02.png"""
|
||||
"""Replace the paths set on the “search test” field by the ones in “replace” field. "_v01" »» "_v02" /folder1/render_v01.png »» /folder1/render_v02.png"""
|
||||
bl_idname = "file.replace_file_path_osc"
|
||||
bl_label = "Replace File Path"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
@ -91,8 +91,7 @@ class replaceFilePath(Operator):
|
|||
# ---------------------- SYNC MISSING GROUPS --------------------------
|
||||
|
||||
class reFreshMissingGroups(Operator):
|
||||
"""Search on the libraries of the linked source and relink groups and link newones if there are. """ \
|
||||
"""Usefull to use with the mesh cache tools"""
|
||||
"""Search on the libraries of the linked source and relink groups and link newones if there are. Usefull to use with the mesh cache tools."""
|
||||
bl_idname = "file.sync_missing_groups"
|
||||
bl_label = "Sync Missing Groups"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
@ -103,3 +102,35 @@ class reFreshMissingGroups(Operator):
|
|||
with bpy.data.libraries.load(group.library.filepath, link=True) as (linked, local):
|
||||
local.groups = linked.groups
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
# ---------------------- COLLECT IMAGES --------------------------
|
||||
|
||||
|
||||
class collectImagesOsc(Operator):
|
||||
"""Collect all images in the blend file and put them in IMAGES folder."""
|
||||
bl_idname = "file.collect_all_images"
|
||||
bl_label = "Collect Images"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
def execute(self, context):
|
||||
|
||||
imagespath = "%s/IMAGES" % (os.path.dirname(bpy.data.filepath))
|
||||
|
||||
if not os.path.exists(imagespath):
|
||||
os.mkdir(imagespath)
|
||||
|
||||
bpy.ops.file.make_paths_absolute()
|
||||
|
||||
for image in bpy.data.images:
|
||||
if not os.path.exists(os.path.join(imagespath,os.path.basename(image.filepath))):
|
||||
shutil.copy(image.filepath, os.path.join(imagespath,os.path.basename(image.filepath)))
|
||||
image.filepath = os.path.join(imagespath,os.path.basename(image.filepath))
|
||||
else:
|
||||
os.remove(os.path.join(imagespath,os.path.basename(image.filepath)))
|
||||
shutil.copy(image.filepath, os.path.join(imagespath,os.path.basename(image.filepath)))
|
||||
image.filepath = os.path.join(imagespath,os.path.basename(image.filepath))
|
||||
|
||||
bpy.ops.file.make_paths_relative()
|
||||
|
||||
return {'FINISHED'}
|
Loading…
Reference in New Issue