From 159356cb41f1f9052fbfa77095530046622e2d1d Mon Sep 17 00:00:00 2001
From: Eugenio Pignataro <info@oscurart.com.ar>
Date: Mon, 11 May 2020 17:22:43 -0300
Subject: [PATCH] OscurarTools: New Feature in renderTokens, now support
 compositor output filepath

---
 oscurart_tools/render/render_tokens.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/oscurart_tools/render/render_tokens.py b/oscurart_tools/render/render_tokens.py
index 2ac8404ee..12c27b154 100644
--- a/oscurart_tools/render/render_tokens.py
+++ b/oscurart_tools/render/render_tokens.py
@@ -25,6 +25,7 @@ from bpy.app.handlers import persistent
 @persistent
 def replaceTokens (dummy):
     global renpath
+    global nodeDict
     tokens = {
     "$Scene":bpy.context.scene.name,
     "$File":os.path.basename(bpy.data.filepath).split(".")[0],
@@ -32,6 +33,15 @@ def replaceTokens (dummy):
     "$Camera":bpy.context.scene.camera.name}
 
     renpath = bpy.context.scene.render.filepath
+    
+    nodeDict = []
+    #compositor nodes
+    for node in bpy.context.scene.node_tree.nodes:
+        if node.type == "OUTPUT_FILE":
+            nodeDict.append([node,node.base_path])   
+            node.base_path = node.base_path.replace("$Scene",tokens["$Scene"]).replace("$File",tokens["$File"]).replace("$ViewLayer",tokens["$ViewLayer"]).replace("$Camera",tokens["$Camera"])
+                      
+            
 
     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)
@@ -41,6 +51,10 @@ def replaceTokens (dummy):
 def restoreTokens (dummy):
     global renpath
     bpy.context.scene.render.filepath = renpath
+    
+    #restore nodes
+    for node in nodeDict:
+        node[0].base_path = node[1]
 
 
 # //RENDER/$Scene/$File/$ViewLayer/$Camera
-- 
GitLab