From 9acacb23d1aa0c6422f43b72a727045966bca89c Mon Sep 17 00:00:00 2001 From: Evan Pratten Date: Sun, 15 Oct 2023 16:58:53 -0400 Subject: [PATCH] Add blender addon --- .../3.x/scripts/addons/y_aligned_camera.py | 54 +++++++++++++++++++ configs/scripts/ewp-sendmail.py | 0 install.conf.yaml | 4 ++ 3 files changed, 58 insertions(+) create mode 100644 configs/blender/3.x/scripts/addons/y_aligned_camera.py mode change 100644 => 100755 configs/scripts/ewp-sendmail.py diff --git a/configs/blender/3.x/scripts/addons/y_aligned_camera.py b/configs/blender/3.x/scripts/addons/y_aligned_camera.py new file mode 100644 index 0000000..0216a4f --- /dev/null +++ b/configs/blender/3.x/scripts/addons/y_aligned_camera.py @@ -0,0 +1,54 @@ +bl_info = { + "name": "Evan's Y-aligned Camera Creator", + "author": "Evan Pratten ", + "version": (1, 0), + "blender": (3, 0, 0), + "description": "Adds a camera that is aligned with the Y axis by default", + "category": "General", +} + +import bpy +from bpy.types import Operator +from bpy_extras.object_utils import AddObjectHelper +import math + + +class OBJECT_OT_add_object(Operator, AddObjectHelper): + """Create a new Camera Object facing +Y""" + + bl_idname = "mesh.add_y_camera" + bl_label = "Add Camera Object facing +Y" + bl_options = {"REGISTER", "UNDO"} + + def execute(self, _): + print("[+Y Camera] Creating new camera and adding to scene at origin") + + # Create a new camera, facing +Y + camera_data = bpy.data.cameras.new(name="Camera") + camera_object = bpy.data.objects.new("Camera", camera_data) + camera_object.rotation_euler[0] = math.radians(90) + + # Add the camera to the scene + bpy.context.scene.collection.objects.link(camera_object) + + return {"FINISHED"} + + +def blender_button_add_y_camera(obj, _): + obj.layout.operator( + OBJECT_OT_add_object.bl_idname, text="+Y Camera", icon="CAMERA_DATA" + ) + + +def register(): + bpy.utils.register_class(OBJECT_OT_add_object) + bpy.types.VIEW3D_MT_add.append( + lambda obj, ctx: blender_button_add_y_camera(obj, ctx) + ) + + +def unregister(): + bpy.utils.unregister_class(OBJECT_OT_add_object) + bpy.types.VIEW3D_MT_add.remove( + lambda obj, ctx: blender_button_add_y_camera(obj, ctx) + ) diff --git a/configs/scripts/ewp-sendmail.py b/configs/scripts/ewp-sendmail.py old mode 100644 new mode 100755 diff --git a/install.conf.yaml b/install.conf.yaml index 03558af..ef3edea 100644 --- a/install.conf.yaml +++ b/install.conf.yaml @@ -22,6 +22,7 @@ - ~/.config/git - ~/.cargo - ~/.config/user-tmpfiles.d + - ~/.config/blender/3.6/scripts/addons # Program plugins - ~/.local/share/nautilus/scripts/ - ~/houdini19.5 @@ -72,6 +73,9 @@ ~/.config/autostart/gnome-keyring-ssh.desktop: configs/autostart/gnome-keyring-ssh.desktop ~/.config/autostart/logid.desktop: configs/autostart/logid.desktop + # Blender Addons + ~/.config/blender/3.6/scripts/addons/y_aligned_camera.py: configs/blender/3.x/scripts/addons/y_aligned_camera.py + # Others ~/.config/tabset: configs/tabset ~/.config/rofi: configs/rofi