Blender addon development

Where do I start learning addon development. Most of the blender 2.8 addon tutorials are migratory from older versions. For someone who is completely new to addon development and want to get started with 2.8, are there any resources?

I’d love to see some structured beginners advice too. I managed to modify an old python script I found online to work in 2.8. I was immensely pleased with myself :stuck_out_tongue: But I’d love to learn more.

2 Likes

I’m bumping this thread because I too would like to learn some simple Python scripting in Blender!

Hi,

When I started learning the Blender API and addon development, I found the VS Studio Code editor and the addon “Blender Developer” by Jacques Lucke very useful. To get you started, here are some brief guidelines and code examples to create a simple addon template. When you have this working, you can continue building some simple features like adding a new object or similar. I assume you have some basic understanding of Python.

  1. Install VS Studio Code and the “Blender Developer” plugin. Check the documentation on how to use it, it’s very easy to get started with. Make sure that you can start Blender from the plugin (CTRL+SHIFT+P and search for “Blender”).

  2. Create a folder on disk for your project, open this folder in VS Code and create the following files (I find it easier to organize the code if you split it in several files, one for “operators” etc):

__init__.py
bl_info = {
    "name": "My First Addon",
    "author": "Nn Nn",
    "description": "This is my first addon...",
    "version": (1, 0),
    "blender": (2, 80, 0),
    "location": "View3D > Object > My First Addon",
    "warning": "",
    "category": "Object"
}

# Blender imports
import bpy
import bpy.types

# Import Panel
from .panel import MYFIRSTADDON_PT_main_panel

# Import Operators
from .operators import MYFIRSTADDON_OT_test

classes = (MYFIRSTADDON_OT_test, 
           MYFIRSTADDON_PT_main_panel)

def register():
    from bpy.utils import register_class
    for cls in classes:
        register_class(cls)

def unregister():
    from bpy.utils import unregister_class
    for cls in reversed(classes):
        unregister_class(cls)
        

if __name__ == "__main__":
    register()

operators.py
# Blender imports
import bpy.types


class MYFIRSTADDON_OT_test(bpy.types.Operator):
    """Operator for my first addon..."""     

    bl_idname = "myfirstaddon.test"     
    bl_label = "This operator does some fancy things..."         
    bl_options = {'REGISTER'}
        

    def execute(self, context):
        scene = context.scene
        object = context.object
  
        # Your code goes here...
        print('Operator called!')

        return {'FINISHED'}   

panel.py
# Blender imports
import bpy.types


class MYFIRSTADDON_PT_main_panel(bpy.types.Panel):
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_label = "My First Addon"
    bl_context = "objectmode"
    bl_category = "My First Addon"

    def draw(self, context):
        layout = self.layout
       
        row = layout.row()
        row.operator("myfirstaddon.test", text="My operator")

If everything works OK, this will add a new tab in the “N-panel” with a button, “My operator”. Good luck with the coding!

1 Like

Wow, that is great! I don’t have VS but that’s the least of my problems; any text editor will do in a pinch. I’m gonna play around in IDLE and see what happens! Thanks!