hello,
You GUI should update when something change in the scene.
In this case you can use CoreMessage to trigger an update function if something have change.
Check the value and update your GeDialog accordingly
class MyDialog(c4d.gui.GeDialog):
def __init__(self):
self.comboBox = 2000
self.FK = 2001
self.IK = 2002
def CreateLayout(self):
cycle = self.AddComboBox(self.comboBox, c4d.BFH_SCALEFIT, 100, 10, False, True);
self.AddChild(self.comboBox, self.FK, "FK");
self.AddChild(self.comboBox, self.IK, "IK");
return True
def InitValues(self):
self.CheckValues()
return True
def FindTag(self):
# retrieves the tag where we want to change the value of the field
doc = c4d.documents.GetActiveDocument()
if doc is None:
raise ValueError("no active document")
op = doc.GetActiveObject()
if op is None:
raise ValueError("no active Object")
tag = op.GetTag(1019561)
if tag is None:
raise ValueError("no IK tag found on this object")
return tag
def CheckValues(self):
# Check the value of the field of the tag and set the value of the gadget
tag = self.FindTag()
if tag[c4d.ID_CA_IK_TAG_IKFK] == 1.0:
self.SetInt32(self.comboBox, self.FK)
else:
self.SetInt32(self.comboBox, self.IK)
def Command(self, id, msg):
# Reacts to the change of the combo box, update the tag value.
if id == self.comboBox:
value = self.GetInt32 (self.comboBox)
if value == self.FK:
self.FindTag()[c4d.ID_CA_IK_TAG_IKFK] = 1.0
else:
self.FindTag()[c4d.ID_CA_IK_TAG_IKFK] = 0.0
c4d.EventAdd()
return True
def CoreMessage(self, id, msg):
# If something have change in the scene, check the values
if (id == c4d.EVMSG_CHANGE):
self.CheckValues()
return True
Cheers,
Manuel