Tried this code, but it seems have some issue, can't figure it out (need your help):

import bpy

def my_handler(scene):
    #print("Active object:", scene.objects.active.name)
    print("Active object:", bpy.context.view_layer.objects.active.name)


the old original code is commented.

  • $\begingroup$ can u please elaborate the issues? syntax error? isn't called? if yes, when isn't it called...? $\endgroup$
    – Chris
    Dec 1, 2022 at 9:43
  • $\begingroup$ oh sorry, I restarted blender and used it again and it seems to work as expected. So I'll leave the question so others can do the same. $\endgroup$
    – APEC
    Dec 1, 2022 at 10:07
  • $\begingroup$ Note this won't fire only every time the object is changed, it will fire every time anything is changed. $\endgroup$
    – Gorgious
    Dec 1, 2022 at 11:59
  • $\begingroup$ Gorgious, you are right. How to handle here blender.stackexchange.com/questions/150809/… $\endgroup$
    – APEC
    Dec 1, 2022 at 15:31


You must log in to answer this question.

Browse other questions tagged .