How do I set the render size?

I am trying to script up some text to set the render size. I found the basis for this in another script. Does it look correct? It doesn’t seem to be working for me yet…


DATAHASH = {
    'SIZEX': Draw.Create(320),
    'SIZEY': Draw.Create(200)
}   

def CheckCam():
   frame = Blender.Get("curframe")
   if (frame==1):
      cntx.imageSizeX(State[Draw.Create('SizeX')])
      cntx.imageSizeY(State[Draw.Create('SizeY')])
      Scene.getCurrent().setCurrentCamera(Object.Get("Camera01"))


try just:

cntx.imageSizeX(DATAHASH['SIZEX']);

I got it working… thanks for the help. The problem was that I didn’t have cntx defined before. Then I just got rid of the vars for SizeX and SizeY. That’s OK…



import Blender
from Blender import *

## Get scene data
cur = Scene.getCurrent()

## Get the current image render context
cntx = cur.getRenderingContext()  

def CheckCam():
   frame = Blender.Get("curframe")
   if (frame==1):
      Scene.getCurrent().setCurrentCamera(Object.Get("Camera01"))
      cntx.imageSizeX(1000)
      cntx.imageSizeY(1000)

   if (frame==2):
      Scene.getCurrent().setCurrentCamera(Object.Get("Camera02"))
      cntx.imageSizeX(1280)
      cntx.imageSizeY(1024)


BTW, you might be interested in this script. This is the basis for a script which will generate many nice still images of an object plus the necessary images for the quicktime 3d view I believe you are familiar with. I can set 6 cameras at the desired location and point them in all 6 directions. Those cameras will have the proper lens size, 16 if I remember? Then, I can also have 4 or 5 other cameras with 25 or 35mm lenses placed around the model as well.

After I get this all set up and the script is in place, I can simply render an animation that is say 10 frames long. I will produce the 6 necessary images for GoCubic plus 4 or 5 still frames of the model from different angles. This is an awesome ability. I can now model all evening. When I am done, I can simply hit ANIM. When I wake up the next day, I have 10 high res images all named and placed in the proper directory for me. I just have to run GoCubic on some of them to get the 3d mov file.

I no longer have to spend hours rendering and waiting for the files to get created, then saving the jpg and switching cameras and repeating. I used to waste so much time doing this. Now I will be able to kick it all out with the press of one button. Very very cool…

reap

nice. rendering context settings provide nice way for automating.

but it was sooo easy in (pre 2.33) old days: you could save a lot of typing and simply do (this won’t work now):
scn=Blender.Scene.GetCurrent()
scn.frameSettings(1, 250 , myframe)
scn.setWinSize([720,576])

(and use the ‘Anim’ renderbutton)

which was waaay more convenient for quick hacks via blender’s text editor.