Make Python Generator update on User Data change
-
Hi, I have a Python Generator that uses fields with SampleListSimple() function. It should change the position of generated geometry based on provided field sample values. Fields are connected to Pyhton Generator with User Data -> Field List. It works good, I can tweak field values and Pyhon Generator updates accordingly, but if I try to turn off / turn on / add / remove field from field list, Generator is not updated accordingly to that event (however if I turn off field itself, not in user data but in objects tree, generator updates well).
So far I managed to get that event:
def message(id, data): if(id==c4d.MSG_DESCRIPTION_POSTSETPARAMETER): flId = eval(str(data['descid']))[1][0] if flId == 1: myFieldList = op[c4d.ID_USERDATA, 1] #trying update global FieldList value, no sucess
I've tried to push "force update" button on this event, but got error that says button execution should be only from main thread. So the question -- how to properly refresh Python Generator when parameters of fields in FieldList User Data (such as turn on/off, name, blending, opacity) are changed?
-
Hello @karpique,
Thank you for reaching out to us. Please follow our support procedures in future regarding providing a question that is for repeatable, we otherwise might refuse support.
Your problem is likely tied to cache optimization being enabled, this has been discussed before here for example. To not write essays due to the unbound nature of your question, I answer in the video below.
Cheers,
Ferdinand -
Thansk so much for the video, that was a deep dive! For my issue, I resolved it like this:
def message(id, data): if(id==c4d.MSG_DESCRIPTION_POSTSETPARAMETER): userDataID = eval(str(data['descid']))[1][0] if userDataID in [2, 4, 5]: c4d.CallButton(op, c4d.OPYTHON_MAKEDIRTY)
so, if any user data touched (including fieldlist), the generator updates itself.