Skip to content

Latest commit

 

History

History
44 lines (33 loc) · 1.54 KB

useful.md

File metadata and controls

44 lines (33 loc) · 1.54 KB

Useful Resources:

Interactive debugging

Paste this into your code to drop into an interactive Python interpreter in this line:

__import__('code').interact(local=dict(globals(), **locals()))

Change property without triggering update

If you want to edit a Blender property without triggering it's update function, access it like in this example:

class Test:
    def update_a(self, context):
        # Wrong, would cause endless recursion
        # self.b = str(self.a)
        # Correct, does not trigger b's update method
        self["b"] = str(self.a)
        
    def update_b(self, context):
        self["a"] = int(self.b)

    a: IntProperty(update=update_a)
    b: StringProperty(update=update_b)

Creating a hidden datablock

Datablocks wich have a name starting with "." (dot) are hidden in UI dropdowns/menus by default, similar to hidden files on Linux. The user can still type in a dot in the search field to see all the hidden datablocks.

The VRay addon uses this to create hidden helper textures, for example to use their colorramp in a custom node (as a workaround to the fact that addons can't create colorramps).

Subscribe to a Blender-defined property

It is possible to attach a listener function to an existing property via bpy.msgbus: