1

I'm trying to follow the example from this post on Blender Stack Exchange: Example of persistent usage of «bpy.msgbus» and how to manage it?

I want to catch the event when a color has been added to a Palette. I have tried subscribe_to = bpy.types.Palette, "colors" and subscribe_to = bpy.context.tool_settings.image_paint.palette.path_resolve("colors", False), but neither has worked. Can anyone please advise how I may detect when a Palette's colors have changed? Thank you!

    subscribe_to = bpy.types.Palette, "colors"
bpy.msgbus.subscribe_rna(
    key=subscribe_to,
    owner=subscription_owner,
    args=("a", "b", "c"),
    notify=notification_handler,
    options={"PERSISTENT",}
)

quellenform
  • 35,177
  • 10
  • 50
  • 133
  • Thank you for the reply, @HarryMcKenzie. Sure thing (In Texture Paint Mode: Tool > Brush Settings > Color Palette Panel: https://snipboard.io/SFsQkG.jpg – Dr. Pontchartrain Jul 21 '23 at 04:06
  • According to this link, https://b3d.interplanety.org/en/message-bus/, the Message Bus doesn't work with changes in the Viewport, which is how I was creating Colors (Sampling colors with Alt+ S + Left Click).

    If anyone knows of an alternate way to listen to this change, I'd appreciate learning it! The article says message bus DOES work with changes in the Python API, so bpy.context.tool_settings.image_paint.palette.colors should work.

    – Dr. Pontchartrain Jul 21 '23 at 04:24
  • take note the msgbus capability is very limited. it might not be possible. – Harry McKenzie Jul 21 '23 at 04:52
  • 1
    i did some more digging and it seems like it's really not supported if not a bug. maybe file a bug report. – Harry McKenzie Jul 22 '23 at 16:15
  • I REALLY appreciate that @HarryMcKenzie. Thank you! I will file a bug report. – Dr. Pontchartrain Jul 22 '23 at 16:26
  • Oops, too late: https://projects.blender.org/blender/blender/issues/110383 – Dr. Pontchartrain Jul 22 '23 at 16:44
  • 1
    haha no worries. but i would keep ur bug report simple with a simple code example because the other part is not relevant – Harry McKenzie Jul 22 '23 at 16:47

0 Answers0