Starting from September 10th, 2024, I began building my own Blender add-on. Initially, I thought it would be straightforward to configure Visual Studio Code (VS Code) for developing Blender add-ons. However, I soon found that setting up VS Code for this purpose was quite tedious. After a few days of trial and error, I finally discovered a standardized and sustainable process for developing Blender add-ons using VS Code. In this blog post, I'll share my step-by-step guide to help you set up VS Code for Blender add-on development.
Steps to Set Up VS Code for Blender Add-on Development
- Open VS Code
- Activate the Blender Development Extension
- Install the following extension: Blender Development.
- Open the extension settings and enable the option:
Reload addon in Blender when a document is saved
.
- Open Your Project Folder in VS Code
- Create a New Add-on
- Press
Ctrl + Shift + P
to open the Command Palette. - Search for
New Addon
and selectSimple
.
- You will be prompted to provide a name for the add-on, developer name, support for previous Blender versions, and the folder where the development files will be stored.
This will generate the required files for a basic Blender add-on.
- Press
- Start Blender from VS Code
- Open the Command Palette again with
Ctrl + Shift + P
and search forBlender Start
. - You will be prompted to select the specific version of Blender where you want to install the add-on.
Blender should now open automatically. To activate the add-on, go to
Preferences
>Add-ons
and search for[Your Add-on Name]
.At this point, the add-on is registered but not yet functional.
- Open the Command Palette again with
- Import the Blender Package
- Open a
*.py
file in your project and add the following code:import bpy
If you encounter an error stating that
bpy
is not found, proceed to the next step. - Open a
- Select the Python Interpreter
- Press
Ctrl + Shift + P
to open the Command Palette and search forSelect Interpreter
. - Choose the Python version installed on your system (typically located inside the
C:
drive on Windows). - Open the Windows Terminal with "Run as Administrator" privileges and run the following command:
This command installs a fake version of thepip install fake-bpy-module
bpy
module, which simulates the Blender Python API. You can find more details about this package here.
- Press
- Verify Everything is Working
- Open VS Code again, and everything should now be functioning correctly!