Hello, there!
The following code works(Python Tag). Whenever I press the User Data button, the global position coordinates from the object(cube) get stored in three separate User Data fields. Great!
The issue rises whenever the input in those three fields gets done manually, via keyboard, which is something totally valid for my purposes. Console says "index out of depth", and I just can't figure out how to avoid going that deep with the "if" comparisons, I mean, my goal is to stop passing the "if" tests whenever the messages come from inputs other than the User Data button.
import c4d
def message(msg_type, data):
if msg_type == c4d.MSG_NOTIFY_EVENT:
event_data = data['event_data']
if event_data['msg_id'] == c4d.MSG_DESCRIPTION_COMMAND:
desc_id = event_data['msg_data']['id']
if desc_id[1].id != None: #Trying to avoid 'Index Out of Depth' console messages
if desc_id[1].dtype == c4d.DTYPE_BUTTON:
#Gets Driver Object Global Matrix and stores its Global Position
o = doc.SearchObject("Drv")
if o:
m = o.GetMg()
pos = m.off
#Update Button Hit
if desc_id[1].id == 1:
op[c4d.ID_USERDATA,1][c4d.ID_USERDATA,2] = pos[0]
op[c4d.ID_USERDATA,1][c4d.ID_USERDATA,4] = pos[1]
op[c4d.ID_USERDATA,1][c4d.ID_USERDATA,3] = pos[2]
c4d.EventAdd()
else:
return
def main():
pass
Thanks for your Attention,
Leo