[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4208] contrib/py/scripts/addons/ oscurart_tools/oscurart_render.py: Oscurart version 3.1 - Ready

Eugenio Pignataro info at oscurart.com.ar
Fri Jan 25 19:17:34 CET 2013


Revision: 4208
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4208
Author:   oscurart
Date:     2013-01-25 18:17:34 +0000 (Fri, 25 Jan 2013)
Log Message:
-----------
Oscurart version 3.1 - Ready

Added Paths:
-----------
    contrib/py/scripts/addons/oscurart_tools/oscurart_render.py

Added: contrib/py/scripts/addons/oscurart_tools/oscurart_render.py
===================================================================
--- contrib/py/scripts/addons/oscurart_tools/oscurart_render.py	                        (rev 0)
+++ contrib/py/scripts/addons/oscurart_tools/oscurart_render.py	2013-01-25 18:17:34 UTC (rev 4208)
@@ -0,0 +1,456 @@
+import bpy
+import math
+import sys
+import os
+import stat
+import bmesh
+import time
+import random
+
+##-------------------------------- RENDER ALL SCENES ----------------------------
+
+
+def defRenderAll (frametype):
+    LISTMAT=[]
+    SCENES=bpy.data.scenes[:]
+    ACTSCENE=bpy.context.scene
+    FC=bpy.context.scene.frame_current
+    FS=bpy.context.scene.frame_start
+    FE=bpy.context.scene.frame_end
+    print("---------------------")
+    for OBJECT in bpy.data.objects[:]:
+        SLOTLIST=[]
+        try:
+            if OBJECT.type=="MESH" or OBJECT.type == "META" or OBJECT.type == "CURVE":
+                for SLOT in OBJECT.material_slots[:]:
+                    SLOTLIST.append(SLOT.material)
+
+                LISTMAT.append((OBJECT,SLOTLIST))
+
+        except:
+            pass
+    for SCENE in SCENES:
+        PROPTOLIST=list(eval(SCENE['OVERRIDE']))
+        CURSC= SCENE.name
+        PATH = SCENE.render.filepath
+        ENDPATH = PATH
+        FILEPATH=bpy.data.filepath
+        bpy.context.window.screen.scene=SCENE
+        if frametype == True:
+            bpy.context.scene.frame_start=FC
+            bpy.context.scene.frame_end=FC
+            bpy.context.scene.frame_end=FC
+            bpy.context.scene.frame_start=FC
+        try:
+            for OVERRIDE in PROPTOLIST:
+                for OBJECT in bpy.data.groups[OVERRIDE[0]].objects[:]:
+                    if OBJECT.type == "MESH" or OBJECT.type == "META" or OBJECT.type == "CURVE":
+                        for SLOT in OBJECT.material_slots[:]:
+                            SLOT.material=bpy.data.materials[OVERRIDE[1]]
+        except:
+            pass
+        SCENENAME=os.path.basename(FILEPATH.rpartition(".")[0])
+        LAYERLIST=[]
+        for layer in SCENE.render.layers:
+            if layer.use == 1:
+                LAYERLIST.append(layer)
+        for layers in LAYERLIST:
+            for rl in LAYERLIST:
+                rl.use= 0
+            print("SCENE: "+CURSC)
+            print("LAYER: "+layers.name)
+            print("OVERRIDE: "+str(PROPTOLIST))
+            SCENE.render.filepath = "%s/%s/%s/%s/%s_%s_%s_" % (PATH,SCENENAME,CURSC,layers.name,SCENENAME,SCENE.name,layers.name)
+            SCENE.render.layers[layers.name].use = 1
+            bpy.ops.render.render(animation=True, write_still=True, layer=layers.name, scene= SCENE.name)
+            print("DONE")
+            print("---------------------")
+
+        for layer in LAYERLIST:
+            layer.use = 1
+        SCENE.render.filepath = ENDPATH
+        for OBJECT in LISTMAT:
+            SLOTIND=0
+            try:
+                for SLOT in OBJECT[1]:
+                    OBJECT[0].material_slots[SLOTIND].material=SLOT
+                    SLOTIND+=1
+            except:
+                print("OUT OF RANGE")
+        if frametype == True:
+            SCENE.frame_start=FS
+            SCENE.frame_end=FE
+            SCENE.frame_end=FE
+            SCENE.frame_start=FS
+    bpy.context.window.screen.scene=ACTSCENE
+
+
+class renderAll (bpy.types.Operator):
+    bl_idname="render.render_all_scenes_osc"
+    bl_label="Render All Scenes"
+
+    frametype=bpy.props.BoolProperty(default=False)
+
+
+    def execute(self,context):
+        defRenderAll(self.frametype)
+        return {'FINISHED'}
+
+
+##--------------------------------RENDER SELECTED SCENES----------------------------
+
+
+bpy.types.Scene.use_render_scene = bpy.props.BoolProperty()
+
+
+def defRenderSelected(frametype):
+    ACTSCENE = bpy.context.scene
+    LISTMAT = []
+    SCENES = bpy.data.scenes[:]
+    FC = bpy.context.scene.frame_current
+    FS = bpy.context.scene.frame_start
+    FE = bpy.context.scene.frame_end
+    for OBJECT in bpy.data.objects[:]:
+        SLOTLIST=[]
+        try:
+            if OBJECT.type == "MESH" or OBJECT.type == "META" or OBJECT.type == "CURVE":
+                for SLOT in OBJECT.material_slots[:]:
+                    SLOTLIST.append(SLOT.material)
+
+                LISTMAT.append((OBJECT,SLOTLIST))
+        except:
+            pass
+    for SCENE in SCENES:
+        if SCENE.use_render_scene:
+            PROPTOLIST = list(eval(SCENE['OVERRIDE']))
+            CURSC = SCENE.name
+            PATH = SCENE.render.filepath
+            ENDPATH = PATH
+            FILEPATH = bpy.data.filepath
+            print("---------------------")
+            bpy.context.window.screen.scene = SCENE
+            if frametype  ==  True:
+                bpy.context.scene.frame_start = FC
+                bpy.context.scene.frame_end = FC
+                bpy.context.scene.frame_end = FC
+                bpy.context.scene.frame_start = FC
+            try:
+                for OVERRIDE in PROPTOLIST:
+                    for OBJECT in bpy.data.groups[OVERRIDE[0]].objects[:]:
+                        if OBJECT.type == "MESH" or OBJECT.type == "META" or OBJECT.type == "CURVE":
+                            for SLOT in OBJECT.material_slots[:]:
+                                SLOT.material=bpy.data.materials[OVERRIDE[1]]
+            except:
+                pass
+            SCENENAME=os.path.basename(FILEPATH.rpartition(".")[0])
+            LAYERLIST=[]
+            for layer in SCENE.render.layers:
+                if layer.use == 1:
+                    LAYERLIST.append(layer)
+            for layers in LAYERLIST:
+                for rl in LAYERLIST:
+                    rl.use= 0
+                print("SCENE: "+CURSC)
+                print("LAYER: "+layers.name)
+                print("OVERRIDE: "+str(PROPTOLIST))
+                SCENE.render.filepath = "%s/%s/%s/%s/%s_%s_%s_" % (PATH,SCENENAME,CURSC,layers.name,SCENENAME,SCENE.name,layers.name)
+                SCENE.render.layers[layers.name].use = 1
+                bpy.ops.render.render(animation=True, layer=layers.name, write_still=True, scene= SCENE.name)
+                print("DONE")
+                print("---------------------")
+            for layer in LAYERLIST:
+                layer.use = 1
+            SCENE.render.filepath = ENDPATH
+            for OBJECT in LISTMAT:
+                SLOTIND = 0
+                try:
+                    for SLOT in OBJECT[1]:
+                        OBJECT[0].material_slots[SLOTIND].material = SLOT
+                        SLOTIND += 1
+                except:
+                    print("OUT OF RANGE")
+            if frametype == True:
+                SCENE.frame_start = FS
+                SCENE.frame_end = FE
+                SCENE.frame_end = FE
+                SCENE.frame_start = FS
+    bpy.context.window.screen.scene = ACTSCENE
+
+
+class renderSelected (bpy.types.Operator):
+    bl_idname="render.render_selected_scenes_osc"
+    bl_label="Render Selected Scenes"
+
+    frametype=bpy.props.BoolProperty(default=False)
+
+    def execute(self,context):
+        defRenderSelected(self.frametype)
+        return {'FINISHED'}
+
+
+
+
+##--------------------------------RENDER CURRENT SCENE----------------------------
+
+
+def defRenderCurrent (frametype):
+    LISTMAT = []
+    SCENE = bpy.context.scene
+    FC = bpy.context.scene.frame_current
+    FS = bpy.context.scene.frame_start
+    FE = bpy.context.scene.frame_end
+
+    print("---------------------")
+    for OBJECT in bpy.data.objects[:]:
+        SLOTLIST = []
+        try:
+            if OBJECT.type == "MESH" or OBJECT.type == "META" or OBJECT.type == "CURVE":
+                for SLOT in OBJECT.material_slots[:]:
+                    SLOTLIST.append(SLOT.material)
+                LISTMAT.append((OBJECT,SLOTLIST))
+        except:
+            pass
+    PROPTOLIST = list(eval(SCENE['OVERRIDE']))
+    CURSC = SCENE.name
+    PATH = SCENE.render.filepath
+    ENDPATH = PATH
+    FILEPATH = bpy.data.filepath
+    if frametype == True:
+        bpy.context.scene.frame_start = FC
+        bpy.context.scene.frame_end = FC
+        bpy.context.scene.frame_end = FC
+        bpy.context.scene.frame_start = FC
+    try:
+        for OVERRIDE in PROPTOLIST:
+            for OBJECT in bpy.data.groups[OVERRIDE[0]].objects[:]:
+                if OBJECT.type == "MESH" or OBJECT.type == "META" or OBJECT.type == "CURVE":
+                    for SLOT in OBJECT.material_slots[:]:
+                        SLOT.material = bpy.data.materials[OVERRIDE[1]]
+    except:
+        pass
+    SCENENAME=os.path.basename(FILEPATH.rpartition(".")[0])
+    LAYERLIST=[]
+    for layer in SCENE.render.layers:
+        if layer.use == 1:
+            LAYERLIST.append(layer)
+    for layers in LAYERLIST:
+        for rl in LAYERLIST:
+            rl.use= 0
+        print("SCENE: "+CURSC)
+        print("LAYER: "+layers.name)
+        print("OVERRIDE: "+str(PROPTOLIST))
+        SCENE.render.filepath = "%s/%s/%s/%s/%s_%s_%s_" % (PATH,SCENENAME,CURSC,layers.name,SCENENAME,SCENE.name,layers.name)
+        SCENE.render.layers[layers.name].use = 1
+        bpy.ops.render.render(animation=True, layer=layers.name, write_still=1, scene= SCENE.name)
+        print("DONE")
+        print("---------------------")
+    for layer in LAYERLIST:
+        layer.use = 1
+    SCENE.render.filepath = ENDPATH
+    for OBJECT in LISTMAT:
+        SLOTIND = 0
+        try:
+            for SLOT in OBJECT[1]:
+                OBJECT[0].material_slots[SLOTIND].material=SLOT
+                SLOTIND += 1
+        except:
+            print("FUERA DE RANGO")
+    if frametype == True:
+        SCENE.frame_start = FS
+        SCENE.frame_end = FE
+        SCENE.frame_end = FE
+        SCENE.frame_start = FS
+
+
+class renderCurrent (bpy.types.Operator):
+    bl_idname="render.render_current_scene_osc"
+    bl_label="Render Current Scene"
+
+    frametype=bpy.props.BoolProperty(default=False)
+
+    def execute(self,context):
+
+        defRenderCurrent(self.frametype)
+
+        return {'FINISHED'}
+
+
+##--------------------------RENDER CROP----------------------
+bpy.types.Scene.rcPARTS = bpy.props.IntProperty(default=0, min=2, max=50, step=1)
+
+def OscRenderCropFunc():
+    SCENENAME = os.path.split(bpy.data.filepath)[-1].partition(".")[0]
+    PARTS = bpy.context.scene.rcPARTS
+    CHUNKYSIZE = 1/PARTS

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list