1

Add blender addon

This commit is contained in:
Evan Pratten 2023-10-15 16:58:53 -04:00
parent 056ccf3c36
commit 9acacb23d1
3 changed files with 58 additions and 0 deletions

View File

@ -0,0 +1,54 @@
bl_info = {
"name": "Evan's Y-aligned Camera Creator",
"author": "Evan Pratten <ewpratten@gmail.com>",
"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)
)

0
configs/scripts/ewp-sendmail.py Normal file → Executable file
View File

View File

@ -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