Hi I made one add on which can save and load custom props (drive shape keys) and pose bone transform for Armature characters as preset.json with some options.

Then I hope to enhance it which will generate preview image(jpg, or png) with json. (eg When I save "preset.json" from add on UI button,it will auto generate preset.png of current scene preview)

I suppose I can use this module,, bpy.utils submodule (bpy.utils.previews) but do not know clear, how actually it work. What I hope to know is, function whici may generate preview with path which user decided.

I suspect I can mix the funciton with my custom operator class to save json..(so when save the json, same name image file will be genrated as perview)

If someone experience same thing, would you teach me how you achive it(with simple code)?

I suppose I may need to use the bpy.utils.submodule(bpy.utils.previews) but even though I read doc and example (which use the image as UI widgt, but I need not, I only need to know how generate current scene preview as image file)


Though my final goal is same, but I now get some steps, then change tittle.. what I planned is,

  1. render and save view port open GL image with current user scene setting, when save preset.json from my add on UI button

Then I hope to make render and save function, which render view port(Open GL) image and save the image "without image editor>render-image>save"

I plan to use bpy.ops.render.opengl(), to render sumbnail , is there good way, "without open image editor(Render image) and choose slots" but save to the directory with file name, as arguments?

Have someone alrady made simillar (simple) custom funciton ?

  • 1
    $\begingroup$ Have you seen: Batch generate preview/thumbnail image for old files? already? $\endgroup$ – brockmann Dec 1 '20 at 8:09
  • $\begingroup$ Thanks link, yes it teach me some new things, but I feel it is not really what I need. $\endgroup$ – tokikake Dec 2 '20 at 1:03
  • $\begingroup$ MMMM,, I expect if there should be more simple module function, which I simply generate current scene thumbnail with some arguments ^^; $\endgroup$ – tokikake Dec 2 '20 at 1:41

It was actually easy. thanks there is already arguments, to direct output render-image in bpy.ops.render.opengl() (write_still = "True")

then most simple case (if keep current scene render setting), once change path(file name) to render thumbnail(openGL view image), then after generate the img , return path as same as before. (so user may not notice it changed)

import bpy

def render_icons(fname):
    render = bpy.context.scene.render
    upath = render.filepath
    render.filepath = fname
    bpy.ops.render.opengl(animation=False, view_context=False, write_still=True)
    bpy.context.scene.render.filepath = upath

I suppose, to enhance this, untill render, set some render propertys of bpy.context.scene.render to fit as thumbnail, then return all property as same as before. and add option flag (user may manually set those setting, or use preset for icon render)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.