Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bpy
- bl_info = {
- "name": "Resolution Swap",
- "description": "Adds a button to the Output properties panel that swaps the X and Y resolution of the active scene",
- "author": "Your Name",
- "version": (1, 0),
- "blender": (2, 80, 0),
- "location": "Properties > Render > Output",
- "warning": "",
- "wiki_url": "",
- "category": "Render"
- }
- class RESOLUTION_SWAP_OT_swap(bpy.types.Operator):
- """Swap the X and Y resolution of the active scene"""
- bl_idname = "resolution.swap"
- bl_label = "Swap Resolution"
- def execute(self, context):
- scene = context.scene
- # Swap the X and Y resolution
- scene.render.resolution_x, scene.render.resolution_y = scene.render.resolution_y, scene.render.resolution_x
- return {'FINISHED'}
- class RESOLUTION_SWAP_PT_panel(bpy.types.Panel):
- """Creates a panel in the Output properties window"""
- bl_label = "Resolution Swap"
- bl_idname = "RESOLUTION_SWAP_PT_panel"
- bl_space_type = 'PROPERTIES'
- bl_region_type = 'WINDOW'
- bl_context = "output"
- def draw(self, context):
- layout = self.layout
- scene = context.scene
- # Add a button to the panel
- layout.operator("resolution.swap")
- def register():
- bpy.utils.register_class(RESOLUTION_SWAP_OT_swap)
- bpy.utils.register_class(RESOLUTION_SWAP_PT_panel)
- def unregister():
- bpy.utils.unregister_class(RESOLUTION_SWAP_PT_panel)
- bpy.utils.unregister_class(RESOLUTION_SWAP_OT_swap)
- if __name__ == "__main__":
- register()
Advertisement
Add Comment
Please, Sign In to add comment