Skip to content

Instantly share code, notes, and snippets.

@Durman
Created July 7, 2022 10:21
Show Gist options
  • Save Durman/d364ffd796bcee3e3da6aad88865596e to your computer and use it in GitHub Desktop.
Save Durman/d364ffd796bcee3e3da6aad88865596e to your computer and use it in GitHub Desktop.
The way how to get notifications whenever active object is changed in Blender.
import bpy
owner = object()
subscribe_to = (bpy.types.LayerObjects, 'active')
def msgbus_callback(*args):
print("Active object is changed!", args)
bpy.msgbus.subscribe_rna(
key=subscribe_to,
owner=owner,
args=(1, 2, 3),
notify=msgbus_callback,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment