Setting the bake destination image

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
Posts: 0
Joined: Sun Jun 24, 2012 8:05 pm

Setting the bake destination image

Post by trethaller » Wed Aug 08, 2012 9:34 pm

Hi there.
I'm trying to set the bake destination image pragmatically to enable batch bake rendering. There was some threads about this, but the working solution is very ugly and not robust:

Code: Select all['UV Editing'].areas[1].spaces[0].image =[key]
So I decided to give it a new try. It turns out that the last image that was unwrapped in the UV/Image editor will always be the target.

Looking at the source, I found that the IMA_USED_FOR_RENDER flag is used to determine which image is used for rendering.

In imagetexture.c:

Code: Select all

int imagewraposa(...)
    if (ima) {

        /* hack for icon render */
        if (ima->ibufs.first==NULL && (R.r.scemode & R_NO_IMAGE_LOAD))
            return retval;
        ibuf= BKE_image_get_ibuf(ima, &tex->iuser);

        ima->flag|= IMA_USED_FOR_RENDER;
And IMA_USED_FOR_RENDER is then tested in int RE_bake_shade_all_selected(...).

Do you have any idea how to change this (even incidentally) from Python ? I guess anything would be better than using the screens panels

Or maybe it should be exposed ?

Post Reply