Guest User

Blender Swap Res Addon by ChatGPT

a guest
Dec 2nd, 2022
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.56 KB | Software | 0 0
  1. import bpy
  2.  
  3. bl_info = {
  4.     "name": "Resolution Swap",
  5.     "description": "Adds a button to the Output properties panel that swaps the X and Y resolution of the active scene",
  6.     "author": "Your Name",
  7.     "version": (1, 0),
  8.     "blender": (2, 80, 0),
  9.     "location": "Properties > Render > Output",
  10.     "warning": "",
  11.     "wiki_url": "",
  12.     "category": "Render"
  13. }
  14.  
  15.  
  16. class RESOLUTION_SWAP_OT_swap(bpy.types.Operator):
  17.     """Swap the X and Y resolution of the active scene"""
  18.     bl_idname = "resolution.swap"
  19.     bl_label = "Swap Resolution"
  20.  
  21.     def execute(self, context):
  22.         scene = context.scene
  23.  
  24.         # Swap the X and Y resolution
  25.         scene.render.resolution_x, scene.render.resolution_y = scene.render.resolution_y, scene.render.resolution_x
  26.  
  27.         return {'FINISHED'}
  28.  
  29.  
  30. class RESOLUTION_SWAP_PT_panel(bpy.types.Panel):
  31.     """Creates a panel in the Output properties window"""
  32.     bl_label = "Resolution Swap"
  33.     bl_idname = "RESOLUTION_SWAP_PT_panel"
  34.     bl_space_type = 'PROPERTIES'
  35.     bl_region_type = 'WINDOW'
  36.     bl_context = "output"
  37.  
  38.     def draw(self, context):
  39.         layout = self.layout
  40.         scene = context.scene
  41.  
  42.         # Add a button to the panel
  43.         layout.operator("resolution.swap")
  44.  
  45.  
  46. def register():
  47.     bpy.utils.register_class(RESOLUTION_SWAP_OT_swap)
  48.     bpy.utils.register_class(RESOLUTION_SWAP_PT_panel)
  49.  
  50.  
  51. def unregister():
  52.     bpy.utils.unregister_class(RESOLUTION_SWAP_PT_panel)
  53.     bpy.utils.unregister_class(RESOLUTION_SWAP_OT_swap)
  54.  
  55.  
  56. if __name__ == "__main__":
  57.     register()
  58.  
Advertisement
Add Comment
Please, Sign In to add comment