In the latest version 2.8 of Blender developers have made many changes in API, so all the scripts and add-ons written for earlier Blender versions (2.7 and below) have stopped working. To run your add-ons in the new Blender 2.8, you need to port them – correct their code to work properly with the new Blender API.
To enable your add-on in Blender 2.80 you have to make the following changes in code:
Blender has its own built-in text editor for writing scripts and add-ons, but it’s much convenient to develop them in external IDEs that provide the user with more features such as autocomplete, syntax highlighting, integration with version control systems and other tools that make development faster and easier.
One of these IDEs is Visual Studio Code from Microsoft. This is a free universal environment that supports development with various programming languages, including the Blender API language – Python.
When starting Blender from the console it processes all parameters passed through the command line. However, some scripts and add-ons for proper work may require specifying their unique command line arguments. If you specify such additional parameters in the command line, Blender will also try to process them, which is likely to result in an error. Blender provides a special way to exclude such arguments from own processing.
State switches so-called “radio buttons” are used in the case to limit the choice by one value from several available ones. There are a lot of such buttons in the Blender interface, for example, switching between RGB and BW rendering modes or setting the texture mapping mode. Such buttons can be created in the Blender add-ons interface too.
Single add-on or script can contain several different operators, and not all of them may be registered in the API by the register() function. To verify that the required operator is registered in the Blender API, run the following command:
In addition to common panels (N/T/Properties) and their sub-panels, to display the user interface elements while developing Blender add-ons you can also use pop-up panels appearing on the screen when a user presses a certain key combination or perform any action. The simplest example of such panels is the panel that appears when the f6 key is pressed immediately after adding an object (shift+a) to the scene.
Blender API provides developers the ability to create such panels for their add-ons. Let’s consider the creating of a pop-up panel as an example of the “Message box” window.
Storing data in a remote database has become common practice in the development of software products. Blender is no exception. Writing scripts and add-ons, the developer may need to access the database to retrieve from it or write to it the necessary information. MySQL today is one of the most common and widely available databases and is well suited for working with Blender.
The interaction between Blender and MySQL database through the Blender Python API is not difficult, but it needs some preparation before stating:
Sometimes when creating an animation it is necessary to perform some actions according to the timeline or, the same, to the current animation frame number. Binding animation to timeline frames in Blender is possible using the built-in Python API.
As an example, let’s make a simple animation which turns one of the letters of any text from lowercase to uppercase in series.
Sometimes when debugging scripts or add-ons, errors not only interrupt the code execution but also causes the complete closure of Blender together with its system console. This case its impossible to check errors and view errors messages.
To find a failure, Blender can be started from the command line interpreter cmd. In this case, Blender output log is redirected to the cmd window which, when the program falls due to errors, not closed. If Blender closes all error messages stay available to check in the cmd window.
To start Blender from a command line interpreter:
Start the interpreter ( “Start” – Run – cmd)
In the cmd window type the full path to the installed Blender. For example: C:\”Program Files”\blender-2.78a-windows64\blender.exe
Part of the way contains spaces must be enclosed in double quotes – like “Programm Files” in this example.
Blender has an internal text editor to write scripts on Python language. However, this editor is much inferior to specially designed for writing code IDEs. There is no satisfactory autocomplete, comfortable syntax lighting, possibility to organize projects in Blender internal text editor – all those things that determine the speed and ease of code writing. However, it is not difficult to connect and use an external IDE for writing Blender scripts.