[Bf-extensions-cvs] [f7dd03d5] master: Add RenderPath tokens, ...

Eugenio Pignataro noreply at git.blender.org
Tue Jan 1 14:39:03 CET 2019


Commit: f7dd03d5f1c7f8a36d2bf7dfce2538b1ec11a573
Author: Eugenio Pignataro
Date:   Tue Jan 1 10:38:57 2019 -0300
Branches: master
https://developer.blender.org/rBAf7dd03d5f1c7f8a36d2bf7dfce2538b1ec11a573

Add RenderPath tokens,   ...

===================================================================

M	oscurart_tools/__init__.py
A	oscurart_tools/render/render_tokens.py

===================================================================

diff --git a/oscurart_tools/__init__.py b/oscurart_tools/__init__.py
index 9b2817cd..c0aa52bf 100644
--- a/oscurart_tools/__init__.py
+++ b/oscurart_tools/__init__.py
@@ -20,19 +20,19 @@
 
 bl_info = {
     "name": "Oscurart Tools",
-    "author": "Oscurart, CodemanX",
+    "author": "Oscurart",
     "version": (4, 0, 0),
     "blender": (2, 80, 0),
     "location": "View3D > Toolbar and View3D > Specials (W-key)",
     "description": "Tools for objects, render, shapes, and files.",
     "warning": "",
-    "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/"
-                "Scripts/3D_interaction/Oscurart_Tools",
+    "wiki_url": "https://www.oscurart.com.ar",
     "category": "Object",
     }
     
 
 import bpy
+from bpy.app.handlers import persistent
 from bpy.types import Menu
 from oscurart_tools.files import reload_images
 from oscurart_tools.files import save_incremental
@@ -45,6 +45,7 @@ from oscurart_tools.object import distribute
 from oscurart_tools.object import selection
 from oscurart_tools.object import search_and_select
 from oscurart_tools.mesh import apply_linked_meshes
+from oscurart_tools.render import render_tokens
 
 from bpy.types import (
         AddonPreferences,
@@ -145,6 +146,9 @@ def register():
     bpy.types.VIEW3D_MT_edit_mesh_specials.prepend(menu_funcMesh)
     bpy.types.IMAGE_MT_specials.prepend(menu_funcImage)
     bpy.types.VIEW3D_MT_object_specials.prepend(menu_funcObject)
+    bpy.app.handlers.render_pre.append(render_tokens.replaceTokens)
+    bpy.app.handlers.render_post.append(render_tokens.restoreTokens)
+    
 
     from bpy.utils import register_class
     for cls in classes:
diff --git a/oscurart_tools/render/render_tokens.py b/oscurart_tools/render/render_tokens.py
new file mode 100644
index 00000000..88ba2a5d
--- /dev/null
+++ b/oscurart_tools/render/render_tokens.py
@@ -0,0 +1,47 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+
+import bpy
+import os
+
+
+def replaceTokens (dummy):
+    global renpath
+    tokens = {
+    "$Scene":bpy.context.scene.name,
+    "$File":os.path.basename(bpy.data.filepath).split(".")[0],
+    "$ViewLayer":bpy.context.view_layer.name,
+    "$Camera":bpy.context.scene.camera.name}
+    
+    renpath = bpy.context.scene.render.filepath
+    
+    bpy.context.scene.render.filepath = renpath.replace("$Scene",tokens["$Scene"]).replace("$File",tokens["$File"]).        replace("$ViewLayer",tokens["$ViewLayer"]).replace("$Camera",tokens["$Camera"])
+    print(bpy.context.scene.render.filepath)
+
+def restoreTokens (dummy):
+    global renpath
+    bpy.context.scene.render.filepath = renpath
+
+
+# //RENDER/$Scene/$File/$ViewLayer/$Camera
+"""
+bpy.app.handlers.render_pre.append(replaceTokens)
+bpy.app.handlers.render_post.append(restoreTokens)
+"""
\ No newline at end of file



More information about the Bf-extensions-cvs mailing list