- changed status to closed
render icon (with sample) for save file (but non blender scene)
The purpose is only for save pose function which recently added for this add on. but may be useful too.
if there will be some new functions which may save files (not matter for daz or blender etc,, like save pose now work for blender and daz)
For most of preset function, (or save kind of data) I like to see icon which render current scene.. so we can easy load it with visuall. then I do not think it must, but it may not harm anyone who need to use save pose. I mainly use custom preset for blender. Then I made it when I save kind of json . it render openGL then generate images as small icon png. (bpy.ops.render.opengl) with auto set render setting (size etc)
Only thing we need to care, when we render openGL. it overwrite current Render image when user alredy render it. So to aovid it, I add new render slot temporally to keep render-image, then when I save poeset (txt, or json), it auto render icon, then remove the slot and return all render setting which currently used.
I think if Thomas can enhance it I hope to see it with current add on save pose. (or I do not know if blender offer more good function as same as we save blend file with icon now)
Ir is actual parts of code t which I include for my preset custom scripts. so If thomas plan to add icon for pose. check it and enhance or modify as you need please. (I think there should be more smart way,, but I usually content with, when I confirm it work ,,so not plan to clean or remove un-necessary code) And I can not manage perfect the focus with current veiw ratio. (so if THomas know better way modify free please)
def keep_renderset(context):
setdic = {}
rd = context.scene.render
olmode = True
image_set = rd.image_settings
setdic["fp"] = rd.filepath
setdic["rx"] = rd.resolution_x
setdic["ry"] = rd.resolution_y
setdic["per"] = rd.resolution_percentage
setdic["ax"] = rd.pixel_aspect_x
setdic["ay"] = rd.pixel_aspect_y
setdic["ub"] = rd.use_border
setdic["uc"] = rd.use_crop_to_border
setdic["fe"] = rd.use_file_extension
setdic["ow"] = rd.use_overwrite
setdic["st"] = rd.film_transparent
setdic["ff"] = image_set.file_format
setdic["cm"] = image_set.color_mode
setdic["cd"] = image_set.color_depth
setdic["cp"] = image_set.compression
return setdic
def set_renderset(context, fname):
rd = context.scene.render
image_set = rd.image_settings
rd.filepath = fname
rd.resolution_x = 256
rd.resolution_y = 256
rd.resolution_percentage = 100
rd.pixel_aspect_x = 1.0
rd.pixel_aspect_y = 1.0
rd.use_border = True
rd.use_crop_to_border = True
rd.use_file_extension = True
rd.use_overwrite = True
rd.film_transparent = True
image_set.file_format = 'PNG'
image_set.color_mode = 'RGBA'
image_set.color_depth = '8'
image_set.compression = 50
def return_renderset(context, setdic):
rd = context.scene.render
image_set = rd.image_settings
rd.filepath = setdic["fp"]
rd.resolution_x = setdic["rx"]
rd.resolution_y = setdic["ry"]
rd.resolution_percentage = setdic["per"]
rd.pixel_aspect_x = setdic["ax"]
rd.pixel_aspect_y = setdic["ay"]
rd.use_border = setdic["ub"]
rd.use_crop_to_border = setdic["uc"]
rd.use_file_extension = setdic["fe"]
rd.use_overwrite = setdic["ow"]
rd.film_transparent = setdic["st"]
image_set.file_format = setdic["ff"]
image_set.color_mode = setdic["cm"]
image_set.color_depth = setdic["cd"]
image_set.compression = setdic["cp"]
def render_icons(context, fname):
olmode = True
for area in context.screen.areas:
if area.type == 'VIEW_3D':
for space in area.spaces:
if space.type == 'VIEW_3D':
olmode = space.overlay.show_overlays
space.overlay.show_overlays = False
break
rd = context.scene.render
rdic = keep_renderset(context)
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
if context.scene.daz_setting.auto_rd:
set_renderset(context, fname)
bpy.ops.render.opengl(animation=False, write_still=True, view_context=True)
return_renderset(context, rdic)
else:
cpath = rd.filepath
cextension = rd.use_file_extension
rd.filepath = fname
rd.use_file_extension = True
bpy.ops.render.opengl(animation=False, write_still=True, view_context=True)
rd.filepath = cpath
rd.use_file_extension = cextension
rs.active = cslot
for area in context.screen.areas:
if area.type == 'VIEW_3D':
for space in area.spaces:
if space.type == 'VIEW_3D':
space.overlay.show_overlays = olmode
break
I used new scene.props and option, which user decide save peset with icon or not. and if user hope to generate better icon, use current user setting which user decide.
to temporally save current user render setting, then return it after generate png with save json (or duf etc)
(though I suppose Thomas can easy do it,, but may need to consider not overwrite user render image, and setting, then attach actual code which embed in) if you use render.opengl to generate icon
Comments (1)
-
reporter - Log in to comment