I'm trying to get a user data button to change the parameter of a camera using a Python Generator as I was adviced on C4D cafe that this was the only way...I've managed to get it working by acknowledging the button press and printing to the console but for the life of me I can't get it to change the focal length of the camera...
Here's the code I currently have, it's what I assume would work depending on which button you press..The camera focal length is driven by user data so it's sitting in the Python Generator which is the parent.
Here's the file just a simple camera rig I'm trying to make which has button presets...I know it's simple but I just can't get it to pass on the info and feel so lost in python documentation :/
And here's the code...
import c4d
#Welcome to the world of Python
def main():
return c4d.BaseObject(c4d.Onull)
def message(msgId, msgData):
if msgId == c4d.MSG_DESCRIPTION_COMMAND:
if msgData['id'] == c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA), c4d.DescLevel(9)):
op.GetObject()[c4d.ID_USERDATA,8] = 36
print "36mm"
elif msgData['id'] == c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA), c4d.DescLevel(13)):
op.GetObject()[c4d.ID_USERDATA,8] = 50
print "50mm"
elif msgData['id'] == c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA), c4d.DescLevel(15)):
op.GetObject()[c4d.ID_USERDATA,8] = 300
print "80mm"
return True