Userdata not updating correctly on primitive splines & polygons in 2024..
-
Hi, I’ve got a simple but strange case in 2024 (while it was working properly before..)
There’s a simple script to hide userData on a python tag.
Depending on the on/off state of the switchBoolean, 1 of the other 2 pieces of user data needs to be hidden.
This works fine on editable splines & polygons, but not on primitive versions - with the exact same tag..So, there must be something happening on the primitive splines and polygons, which I don’t understand..
The pyTags are set to “generators 499”, so that couldn’t be it.The issue is that on the primitives, when the switch says ON, the user date shown say OFF and visa versa..
And only after clicking the “wrong” boolean on the right, the other version will show up. So I need an extra click to get the right result.
(note: working on Mac right now, haven't tested it yet on PC..)Is there anything new to “updating/redrawing” the UI, or is this something to be fixed in a future update?
Kind regards, Jochem
-
Hello @jochemdk,
thank you for reaching out to us. In short, what you are doing is a violation of the threading restrictions of Cinema 4D. Your main function does not run on the main thread and your changes go therefore unnoticed in a certain sense. Even worse, you could protenially crash Cinema 4D in doing this.
The solution is to offload your work to
message
, as this function often runs on the MT ; but you must still check withc4d.threading.GeIsMainThread
for not being on the MT. In your case you could use MSG_DESCRIPTION_POSTSETPARAMETER as the message to hook into when you want to react to a changed value in the user data.When I was a user myself, I once posted this example, which is a script which populates its own UI once the code is pasted into a Python generator. It hooks into
MSG_GETREALCAMERADATA
to do that (which is a bit hacky), but other than that, is absolutely the same.Cheers,
Ferdinand -
Hi Ferdinand, thx for your answer - although I didn't expect this, considering I never ever had any trouble with the script..
But your point is clear. It means I've got to do some more investigation.. -
Hey @jochemdk,
That is the nature of threading restrictions. It is like crossing the street without looking left and right: It works fine until it doesn't
Cheers,
Ferdinand