diff options
author | Eugenio Pignataro <info@oscurart.com.ar> | 2019-01-01 16:38:57 +0300 |
---|---|---|
committer | Eugenio Pignataro <info@oscurart.com.ar> | 2019-01-01 16:38:57 +0300 |
commit | f7dd03d5f1c7f8a36d2bf7dfce2538b1ec11a573 (patch) | |
tree | e55b1a44877cb090703fe92d3a1f4a2187bf1bd1 /oscurart_tools | |
parent | 00fc9bddbcf8cef1ebfc29f69166e2d5b919f5dc (diff) |
Add RenderPath tokens, ...
Diffstat (limited to 'oscurart_tools')
-rw-r--r-- | oscurart_tools/__init__.py | 10 | ||||
-rw-r--r-- | oscurart_tools/render/render_tokens.py | 47 |
2 files changed, 54 insertions, 3 deletions
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 |