Created
October 10, 2015 06:39
-
-
Save zeffii/c7f78f50ac1bb1bee4f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_largest_3dview_and_switch(): | |
collected_areas = [] | |
for window in bpy.context.window_manager.windows: | |
for area in window.screen.areas: | |
if area.type == 'VIEW_3D': | |
size = area.height * area.width | |
collected_areas.append([size, area, window]) | |
# no 3dview found? use texeditor. | |
if len(collected_areas) == 0: | |
bpy.ops.render.render('INVOKE_DEFAULT') | |
return | |
# else use largest 3dview. | |
for area in sorted(collected_areas, reverse=True): | |
area[1].type = 'IMAGE_EDITOR' | |
w = area[2] | |
override = {'window': w, 'screen': w.screen, 'area': area[1]} | |
bpy.ops.render.render(override) | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment