0
$\begingroup$

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)

#bpy.app.handlers.scene_update_post.append(my_handler)
bpy.app.handlers.depsgraph_update_post.append(my_handler)

the old original code is commented.

$\endgroup$
4
  • $\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

0

You must log in to answer this question.

Browse other questions tagged .