1
$\begingroup$

I could track the object count in a variable and compare it to the size of bpy.context.scene.objects in a draw call, or similarly track the collection keys, but that feels imprecise and perhaps prone to sync issues. I'd much prefer to subscribe to something through msgbus and receive a notification when the size of the object collection changes, for example. But what to subscribe to? I managed to kill Blender a few times while experimenting with various things but so far have come up blank. My best guess is the size of a collection is computed rather than a stored property with RNA that can be used with msgbus, but I'd appreciate knowing for sure. Any smart folks out there who've been msgbus wrangling, I'd sure appreciate any advice, even if it's just to confirm that this is a silly idea. Thanks for your brain rental!

$\endgroup$
4
  • 1
    $\begingroup$ Related blender.stackexchange.com/a/163258/15543 $\endgroup$
    – batFINGER
    Dec 4 '20 at 12:51
  • $\begingroup$ @batFINGER are you... are you God? XD Thanks a million for your input, my friend, much appreciated. I'll read this then go poke Blender with a stick again. $\endgroup$ Dec 4 '20 at 12:57
  • $\begingroup$ @batFINGER The example you've given works for adding objects but not deletion, where the active object property does not change. I don't suppose it's possible to add msgbus hooks for bpy.ops? $\endgroup$ Dec 4 '20 at 13:45
  • 1
    $\begingroup$ It does change to None after the delete operator, however is not picked up by msgbus. An idea would be to make a pointer property to the prior selection, which if None on the next selection indicates it was removed. $\endgroup$
    – batFINGER
    Dec 4 '20 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.