48 lines
1.5 KiB
Plaintext
48 lines
1.5 KiB
Plaintext
bl_info = {
|
|
"name": "Swap Resulotion",
|
|
"blender": (2, 80, 0),
|
|
"category": "Context",
|
|
}
|
|
|
|
import bpy
|
|
|
|
class SwapResolution(bpy.types.Operator):
|
|
"""Resolution Swaping button""" # Use this as a tooltip for menu items and buttons.
|
|
bl_idname = "scene.swap_res" # Unique identifier for buttons and menu items to reference.
|
|
bl_label = "Swap Resolution" # Display name in the interface.
|
|
|
|
|
|
def swap(self, curr_x, curr_y):
|
|
y = curr_x
|
|
x = curr_y
|
|
bpy.context.scene.render.resolution_y = y
|
|
bpy.context.scene.render.resolution_x = x
|
|
|
|
def execute(self, context): # execute() is called when running the operator.
|
|
# The original script
|
|
render = context.scene.render
|
|
self.swap(render.resolution_x, render.resolution_y)
|
|
|
|
return {'FINISHED'} # Lets Blender know the operator finished successfully.
|
|
|
|
class FancyPanel(bpy.types.Panel):
|
|
bl_idname = "test_fancy_panel_for_fun"
|
|
bl_label = "Fancy Panel"
|
|
bl_space_type = 'PROPERTIES'
|
|
bl_region_type = "WINDOW"
|
|
|
|
def draw(self, context):
|
|
self.layout.laber(text="Testing")
|
|
self.layout.operator("scene.swap_res")
|
|
|
|
def register():
|
|
bpy.utils.register_class(SwapResolution)
|
|
bpy.utils.register_class(FancyPanel)
|
|
# bpy.types.VIEW3D_MT_object.append(menu_func) # Adds the new operator to an existing menu.
|
|
|
|
def unregister():
|
|
bpy.utils.unregister_class(SwapResolution)
|
|
bpy.utils.unregister_class(FancyPanel)
|
|
|
|
if __name__ == "__main__":
|
|
register() |