Reading Context Options inside an HDA's Python module

   614   0   1
User Avatar
Member
207 posts
Joined: 11月 2015
Offline
Hi;

I'm not entirely sure what the best way to do what I'm trying to do is, but here's my problem:

I like Context Options! I want to use them to store a color to which I can refer throughout my scene. Right now, I'm doing this by creating a string Context Option (e.g. "color_primary"), and setting it to e.g. "0.1 0.2 0.3"

The trouble is that I have to unwind this via expressions all over the place, which sort of un-does much of the convenience of Context Options. So, I thought I'd make a little HDA to do this for me; then I can just drop my "my_color" HDA node down and it will automagically read and do interesting stuff with my Context Option color.

I have this working now by way of the PythonModule section of my HDA. And, I can use the OnCreated method to pull my code when the node is created, at which point it works as I expect. BUT! If I change the Context Option, I'm not sure how to signal to the node to refresh itself.

I suppose my question, then, is twofold: 1) how do I detect Context Option changes in an HDA's python module code, and 2) feel free to point out all the stupid ways I'm totally misusing all this machinery and suggest a better way to accomplish all this. It would be much easier if I could just store the color as a 'color' type in Context Options, but it's not clear to me how to do that. I could store it as three floats, but that gets gross if I want to add more colors to my setup.
Edited by dhemberg - 2022年9月1日 22:17:13
  • Quick Links