Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugenio Pignataro <info@oscurart.com.ar>2017-04-03 17:23:54 +0300
committerEugenio Pignataro <info@oscurart.com.ar>2017-04-03 17:23:54 +0300
commit7aef9abb9dd1b1939f8256151ad77d34a3554bc0 (patch)
tree3bc165351305db3634d83550610b7a30c3bf6373
parentb862e95e6a55fb2004945299aafaa6773f5eb59b (diff)
New Tool: Collect images.
-rw-r--r--oscurart_tools/__init__.py1
-rw-r--r--oscurart_tools/oscurart_files.py43
2 files changed, 38 insertions, 6 deletions
diff --git a/oscurart_tools/__init__.py b/oscurart_tools/__init__.py
index 57082182..87ff68bd 100644
--- a/oscurart_tools/__init__.py
+++ b/oscurart_tools/__init__.py
@@ -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)
diff --git a/oscurart_tools/oscurart_files.py b/oscurart_tools/oscurart_files.py
index 9582b8ed..f22c833f 100644
--- a/oscurart_tools/oscurart_files.py
+++ b/oscurart_tools/oscurart_files.py
@@ -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'} \ No newline at end of file