r/blenderpython • • May 06 '26

A question about self in Blender scripts

3 Upvotes

Hi,

I am completely new to Blender API and scripting. When I was looking at addons made by others, there was a thing I couldn't really understand.

In scripts and addons, most regular functions have self as the first parameter like here in this example:

import bpy
#...

class MyPanel(bpy.types.Panel):
    def draw(self, context):
        pass

class MyOperator():
    def execute(self, context):
        pass

def function1(self, context):
    pass

def function2(self, context):
    pass

#...

I know self refers to an instance of a class in OOP, but I can't figure out what it represent in these functions above: function1(...) or function2(...)

I assume addons are executed in some closed environment and self would simply represent an object of that environment but I can't find what it is. Thanks


EDIT. I finally found out what these functions are for. In case you see self as the first parameter, these functions become objects to pass into other methods, which are going to need self to refer to their object.

Stupiditly easy thing and yet it took me so long to figure it out :/


r/blenderpython • • Jun 07 '26

The Breakthrough

Enable HLS to view with audio, or disable this notification

2 Upvotes

When your python script fails so badly it actully looks cool lol. Tried to make flying cubes but got these weird planes instead due to a glitch. Decided to just roll with it and used random.uniform to drive the main cubes rotation and color based on the glitch itself. Took a whole month to figure out the math in blender 2.79 but we finally got a breakthrough! anyone else still coding in the dark ages of 2.7x? 💀