sidebar features
sidebar content

Go Back   Blender Artists Forums > General Forums > Python & Plugins

Reply
 
Thread Tools
vico vico is online now
Member
 
Join Date: Mar 2006
Posts: 122
I made a little script for keeping a number of renders inside the image editor, as a form of 'Render History'. I think this is very handy to compare the changes in your render.

You have to load the script in a text editor window, and then enable script links (in the scripts panel), then click new, select the script and choose render as the event that will fire the script. If you like the script you can save this in your user default settings and it will work in any new blender file you make.



This way every time you made a render the script automatically saves the image, load it in the image editor window, assign a name to it, pack it inside your blender file, and then remove it from the drive.




You can have your render history inside blender without doing anything, even if you save your file and open it later you will have your render history.

There is a variable in the script called 'NumRender', you can modify its value to set the number of images you want in your render history.

Here it is:

Code:
#!BPY """ Name: 'Render History' Blender: 245 Group: 'Wizards' Tooltip: 'Automatically pack previous renders in blend file' """ __author__ = ['Victor Barberan'] __version__ = '0.1' __url__ = [''] __bpydoc__ = """ Script for automatically load and pack your previous renders into the blender file. """ # ***** BEGIN GPL LICENSE BLOCK ***** # # Script copyright (C) macouno 2006 # # 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # ***** END GPL LICENCE BLOCK ***** # -------------------------------------------------------------------------- import os, random from Blender import * #This varible define how much renders will be in history NumRender = 5 #the screen name for renders screenName = 'RenderHistory' randomName = 'temp'+str(random.random())[-8:] if event == 'PostRender': #get info scn = Scene.GetCurrent() context = scn.getRenderingContext() renderpath = context.renderPath imagetype = context.imageType tempdir = Get('tempdir') #save the image in png format context.renderPath = tempdir context.imageType = Scene.Render.PNG context.saveRenderedImage(randomName) context.imageType = imagetype context.renderPath = renderpath #get a list with only renderhistory images (recognized with speed = 77) list = Image.Get() imglist = [] for i in list: if i.speed == 77: imglist.append(i) imglist.sort #needed for avoiding .001 automatic blender name extensions for n in range(len(imglist)): imglist[n].name = 'tmp' #rename the previous images, starting from 'name 02' for n in range(len(imglist)): imglist[n].name = screenName+' '+str(n+2).rjust(2,'0') #if there are less images that the limit: load new image and renameit if len(imglist) < NumRender: newImg = Image.Load(tempdir+randomName+'.png') newImg.pack() newImg.speed = 77 #this is for recognize the images that the script have loaded newImg.name = screenName+' 01' newImg.reload() else: #reload last image (wiht the new render) and nameit as the first newImg = imglist[-1] newImg.setFilename(tempdir+randomName+'.png') newImg.reload() newImg.name = screenName+' 01' #remove the rendered image from temp path if os.path.exists(tempdir+randomName+'.png'): os.remove(tempdir+randomName+'.png')
Hope someone find this usefull.

I have tested this in linux, but it should work on any system (i hope), if someone try this in windows or mac please post your results.

Sorry for mi bad english

vico.
............................................
(sorry for my bad english)
If the vast majority does not comply with a law, then the law is in danger, not the people.

Last edited by vico; 05-Jan-08 at 04:10.
#1   Old 05-Jan-08, 04:05   
Reply With Quote


pepeland's Avatar
pepeland pepeland is offline
Member
 
Join Date: Feb 2007
Posts: 68
Very usefull for Me

Daniel
............................................
------------------------------------------
www.pepeland.com
www.pepe-school-land.com
------------------------------------------
#2   Old 10-Jan-08, 14:24   
Reply With Quote
macouno's Avatar
macouno macouno is offline
Member
 
Join Date: Jan 2002
Location: netherlands
Posts: 2,514
hola vico... very nice.. will certainly have to try it out.

Did you see the autosave script I wrote?
http://www.alienhelpdesk.com/python_...utosave_render

It's pretty similar to your script except that mine saves to the hdd not in the blend file..
I'll try yours to see what I prefer, though I'm guessing your file may become quite big?
............................................
http://www.macouno.com
#3   Old 10-Jan-08, 14:29   
Reply With Quote
vico vico is online now
Member
 
Join Date: Mar 2006
Posts: 122
Glad you find it usefull

macouno: of course i have seen and tried your script, in fact your script give me the idea to make this one.
I prefer having the images inside the blender file, because each time i open my file the renders are still in there, but is a matter of preferences . This script purpose is to compare renders while your scene evolves, if you want to keep every render you make, i will definitely prefer your script.
About the blend becoming to big, you can set the number of renders you want to store inside the blend file, with the variable "NumRender".

Maybe we can join our two scripts and make one with a selectable option between saving or packing your renders? .

Other idea is to load the render images as a sequence inside the image editor (packed or not), this way you can compare the renders with just one keystroke, and keep all your render history in one "Image". But i cant find how to load the sequence and add images when produced.

sorry about my bad english

vico.
............................................
(sorry for my bad english)
If the vast majority does not comply with a law, then the law is in danger, not the people.
#4   Old 10-Jan-08, 16:23   
Reply With Quote
wendellramos wendellramos is offline
Member
 
Join Date: Apr 2006
Posts: 1
Congratulations!
Fantastic!

This will save me a lot of work!
#5   Old 12-Apr-08, 21:29   
Reply With Quote
PapaSmurf's Avatar
PapaSmurf PapaSmurf is offline
Member
 
Join Date: Sep 2004
Location: Southeast USA
Posts: 8,455
This sure beats having to remember J to jump between renders. Thanks!
............................................
i<3 Blender, and vandalizing the wiki. My creative website, my public website (in progress), my book, my complete learning Blender video series. and my Vimeo compositing video series.
#6   Old 20-Apr-08, 04:56   
Reply With Quote
JiriH's Avatar
JiriH JiriH is offline
Member
 
Join Date: Dec 2005
Posts: 1,515
I have problems to run the script.
Console warning says:

Traceback (most recent call last):
File "Render History.py", line 58, (in module)
TypeError: expected a string

Can anyone help me, please? Thank you very much.
#7   Old 23-Apr-08, 14:58   
Reply With Quote
macouno's Avatar
macouno macouno is offline
Member
 
Join Date: Jan 2002
Location: netherlands
Posts: 2,514
JiriH, I expect that it says a bit more than that?
............................................
http://www.macouno.com
#8   Old 23-Apr-08, 14:59   
Reply With Quote
JiriH's Avatar
JiriH JiriH is offline
Member
 
Join Date: Dec 2005
Posts: 1,515
Quote:
Originally Posted by macouno View Post
JiriH, I expect that it says a bit more than that?
Unfortunately no. Just these three lines.
#9   Old 24-Apr-08, 06:00   
Reply With Quote
BeBraw's Avatar
BeBraw BeBraw is offline
Member
 
Join Date: Jul 2005
Location: Nifland
Posts: 2,064
JiriH: Check what you have put to your Blender temp directory setting. It apparently isn't returning a string (perhaps None or something...). Or as a temporary hack you could put a valid path to some directory there (or create own below home or use temporary folder of your OS etc.).
............................................
Nothing to see here ... move along.
#10   Old 24-Apr-08, 16:26   
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 19:21.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Logo and website design copyright © 2006 by froodee design bureau. All rights reserved.
Other Blender Sites
new icon Blender Homepage »
The official Blender homepage
new icon BlenderNation »
Fresh Blender News, Every Day
new icon Blenderart Magazine »
Blender articles, tutorials and images.
Blender Headlines
Featured Artwork
Short animation: Barrel by Phlopper
Woolly mammoth by sebastian_k
Photorealistic classic furniture by eMirage
Social BlenderArtists