You're blocking ads, which pay for BlenderNation. Read about other ways to support us.

Blender Python Operator Tutorial


gdquest writes:

In this tutorial, you're going to learn how to create a new feature for a Blender add-on, in Python, using the Operator class. Operator is the bread and buter of add-ons, the base type to extend the program's functionality!

At the very end, you'll see how to create a Pull Request, to contribute your feature or fix to an existing project on GitHub. There are hundreds of projects out there to improve instead of starting from scratch! You will also learn a lot by reading and modifying other people's code, and from the developers themselves.

Operators are Blender's mechanism to add new features to the program. They're a base class that supports undoing, mapping to a button or a keyboard shortcut... Operators can seem a little daunting if you're not comfortable with code at first. They mostly revolve around 3 methods:

  1. poll lets you control when an operator can or cannot run. You return true if you want your feature to be accessible from Blender, from the spacebar search menu, buttons... If you return False from this method, you won't be able to find or use the feature. The idea is you check for what the user is doing and return True or False based on the current context.
  2. invoke is called by Blender when the user clicks a button or uses a keyboard shortcut to use your feature. This method tells you which key the user pressed and gives you access to the mouse position. It's optional, you typically use it to make some calculations and storing values before calling the next method, execute.
  3. execute is called by Blender when you run your feature from code, but you can also run it after invoke. This is where you'll put the core of your feature.

There's more to learn and to say about operators. You can create interactive tools with the operators' fourth common method, modal. But that's beyond the scope of this first tutorial!

About the Author

Nathan GDquest

Designer and author of 200+ free tutorials. Learn Game Creation with Open Source Software!

Leave A Reply

To add a profile picture to your message, register your email address with To protect your email address, create an account on BlenderNation and log in when posting a message.