Page Menu
Home
Search
Configure Global Search
Log In
Files
F8576264
render_viewport_alternative.py
pistol ioan (pistoltoto)
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
pistol ioan (pistoltoto)
Jun 4 2020, 12:20 PM
Size
2 KB
Subscribers
None
render_viewport_alternative.py
View Options
import
os
import
bpy
bl_info
=
{
"name"
:
"Viewport Render (Alternative)"
,
"author"
:
"Jefferson Rausseo <jeffersonrausseo@gmail.com>"
,
"version"
:
(
1
,
0
,
1
),
"blender"
:
(
2
,
82
,
0
),
"location"
:
"3D View > View > Viewport Render (Alternative)"
,
"description"
:
""
,
"category"
:
"Render"
}
class
render_viewport_alternative
(
bpy
.
types
.
Operator
):
bl_idname
=
"render.render_viewport_alternative"
bl_label
=
"Viewport Render (Alternative)"
def
execute
(
self
,
context
):
list_frames
=
tuple
(
i
for
i
in
range
(
context
.
scene
.
frame_start
,
context
.
scene
.
frame_end
+
1
))
path
=
dir_path_abs
(
context
.
scene
.
render
.
filepath
)
image_final_name
=
""
if
context
.
scene
.
render
.
filepath
==
""
:
pass
elif
context
.
scene
.
render
.
filepath
[
len
(
context
.
scene
.
render
.
filepath
)
-
1
]
!=
"/"
:
list_path_text
=
context
.
scene
.
render
.
filepath
.
split
(
"/"
)
image_final_name
=
list_path_text
[
len
(
list_path_text
)
-
1
]
path
=
path
[:
-
(
len
(
image_final_name
))]
format_original
=
context
.
scene
.
render
.
image_settings
.
file_format
if
format_original
==
'JPEG'
or
format_original
not
in
[
'JPEG'
,
'PNG'
]:
context
.
scene
.
render
.
image_settings
.
file_format
=
'JPEG'
image_final_format
=
".jpg"
elif
format_original
==
'PNG'
:
image_final_format
=
".png"
for
frame
in
list_frames
:
context
.
scene
.
frame_set
(
frame
)
bpy
.
ops
.
render
.
opengl
()
image_final
=
''
for
image
in
bpy
.
data
.
images
:
if
image
.
source
==
'VIEWER'
:
image_final
=
image
break
image_final_name_frame
=
"{}{:04d}"
.
format
(
image_final_name
,
frame
)
+
image_final_format
image_final_path
=
os
.
path
.
join
(
path
,
image_final_name_frame
)
image_final
.
save_render
(
image_final_path
)
context
.
scene
.
render
.
image_settings
.
file_format
=
format_original
return
{
'FINISHED'
}
def
dir_path_abs
(
path_relative
):
path
=
os
.
path
.
realpath
(
bpy
.
path
.
abspath
(
path_relative
))
return
path
def
menu_func
(
self
,
context
):
self
.
layout
.
operator
(
render_viewport_alternative
.
bl_idname
,
icon
=
'RENDER_STILL'
)
def
register
():
bpy
.
utils
.
register_class
(
render_viewport_alternative
)
bpy
.
types
.
VIEW3D_MT_view
.
append
(
menu_func
)
def
unregister
():
bpy
.
utils
.
unregister_class
(
render_viewport_alternative
)
bpy
.
types
.
VIEW3D_MT_view
.
remove
(
menu_func
)
if
__name__
==
"__main__"
:
register
()
File Metadata
Details
Attached
Mime Type
text/x-python
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
ed/2e/d034a071ed2c1aa0dfbb66d6a5bc
Attached To
T73956: Viewport Render (and Render Animation) color looks completely off from the Viewport
Event Timeline
Log In to Comment