0
$\begingroup$

I know basically after "render" we may save "Render Result" image or change slot of render, but I hope to use render.opengl() to generate current scene thumbnail with exported json files (kind of shape key preset, or bone pose preset system) without overwrite current "Render image".

bpy aleady offer way to save render.opengl() image to the user defined path, but after all it still generate and overwrite the "Render image" too.

So when I export preset.json, with my script, generated "thumbnail" render.opengl image (it generate tiny viewport render with my setting) It auto overwrite current "Render Result" without intention.

What I hope to do is, use "render.opengl()" then generate image to the defined path as thumbnail, without overwrite current "Render Result" . Is there good way to achive it with bpy?

enter image description here (eg generate as different image name from "Render Result" and remove it, after save json)

(this question related with Render and save " view port render image (openGL)" with python directly?)

$\endgroup$
3
  • $\begingroup$ For non-OpenGL renders, I can use bpy.context.scene.render.filepath to change the output file path. I imagine it's the same with OpenGL, but I haven't tried it, so this is just a comment. $\endgroup$ Commented Dec 4, 2020 at 0:44
  • $\begingroup$ Thanks Chirs, yes actually the render.opengl() function already have arguments, to set generate path. so I could generate thumb-nail with script defined scene setting,the problem is it force to overwrite current "Render Result". so if users did not notice it, it may cause problem.(they just think, save json with thumbnail not expect it auto overwrite "Render result" $\endgroup$
    – tokikake
    Commented Dec 4, 2020 at 0:58
  • 1
    $\begingroup$ I could add new render_slot for the "Render Result" image, (even though I delete Render Result, it seems remain as data,) , then can activate it by bpy ,so I can keep current slot images, but I could not find way to remove the new generate render_slot after generate thumb-nail, without use bpy.ops . there seems no function to remove it with bpy,, (I hope to know, if there is way, without use UI (bpy.ops) $\endgroup$
    – tokikake
    Commented Dec 4, 2020 at 2:36

1 Answer 1

1
$\begingroup$

Though I am still serch and apreciate better answer, but temporally I made new render-slot for "Render Result" image as "icon-img", then when save json, if there is no slot name (icon-img) for "Render Result" make new one, or if there is already "icon-img" slot, set to it as active one.

Then generate json, save render.opengl() image to the user defined path, and return all setting as same as before.

rr = bpy.data.images["Render Result"]
rs = rr.render_slots
cslot = rs.active
fl = False
for slot in rs:
    if slot.name == "icon-slot":
        fl = True
        rs.active = slot
        break
        
if not fl:
    aslot = rs.new(name = "icon-slot")
    rs.active = aslot

(functions to generate json with render.opengl image from blender file exploler)

rs.active = cslot

it seems worked for me.. (but I do not know way to remove icon-slot, without use UI)

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .