Add keyframe to userdata

On 18/10/2017 at 00:05, xxxxxxxx wrote:

I just want to put the keyframe to the userdata, but it does not seem to work.
So I have doubt if Python does not support to add keyframe to userdata.
Pls refer to the following script and advise if anything wrong;

import c4d
from c4d import gui
#Welcome to the world of Python

def main() :
       op = doc.GetActiveObject() #designate the selected object to op

doc.RecordKey(op,[c4d.ID_BASEOBJECT_REL_ROTATION,c4d.VECTOR_X]) #Add the keyframe to Rotation X successfully
       doc.RecordKey(op,[c4d.ID_USERDATA,1]) #could not add keyframe to userdata

c4d.EventAdd()

if __name__=='__main__':
       main()

JH

On 18/10/2017 at 09:43, xxxxxxxx wrote:

Hi JH,

welcome to Plugin Café forums 🙂

The problem is the DescID provided for the user data. DescIDs are indeed a bit more complex and not in every case the simplified version (as you provided it) is enough.

If you write it like so, it should work:

descID = c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA, c4d.DTYPE_SUBCONTAINER, 0), c4d.DescLevel(1, c4d.DTYPE_REAL))
doc.RecordKey(op,descID)

In our C++ docs we also have a manual about DescIDs, which might be an interesting read for Python developers as well.

On 18/10/2017 at 22:24, xxxxxxxx wrote:

Great!!
It works perfect now!

Thanks a lot!

JH