On 19/03/2016 at 23:15, xxxxxxxx wrote:
Hi, i need to execut some functions from my script everytime when user change something in one user data field. Im just a beginer in python sdk and i dont understand very well how it works but i thought a little and i made for my userdata field that i want to listen a clone and i hide it from script(just to store the old value) and i compare always with main field. If something changed i do something. In may case i just change the value of chekbutton.
here my script:
import c4d
def main() :
obj = op.GetObject() #get an object with python tag
ud = obj.GetUserDataContainer() #get an userdata container
ud[2][1][c4d.DESC_HIDE] = True #hide my field copy
obj.SetUserDataContainer(ud[2][0], ud[2][1])
new = obj[c4d.ID_USERDATA,1] #value of my filed that i want to listen
old = obj[c4d.ID_USERDATA,3] #value of clone
if old != new:
obj[c4d.ID_USERDATA,2] = 1 - obj[c4d.ID_USERDATA,2] #change value of radiobutton to oposite
obj[c4d.ID_USERDATA,3] = new #store value of my field to clone
So it works well but it looks like a trick. Is there other method to listen a change in userdata filed?