On 26/08/2014 at 12:39, xxxxxxxx wrote:
Hello,
What kind of plugin do you have? Depending on the plugin type there may be different ways to do what you want.
To add keyframs from Python you need Ctracks, Curves and Ckeys:
# define some value for the key
someValue = random.random() * 200;
#define the time
keyTime = c4d.BaseTime(1)
# get the active object to add some keys
activeObject = doc.GetActiveObject()
if activeObject != None:
# look if there is already a track
track = activeObject.FindCTrack(c4d.ID_BASEOBJECT_REL_POSITION)
# if not create the track
if track == None:
track=c4d.CTrack(activeObject, c4d.DescID(c4d.DescLevel(c4d.ID_BASEOBJECT_REL_POSITION, c4d.DTYPE_VECTOR, 0), c4d.DescLevel(c4d.VECTOR_X, c4d.DTYPE_REAL, 0)))
activeObject.InsertTrackSorted(track)
# now get the track's curve
curve = track.GetCurve()
# and add a key at the specified time
added = curve.AddKey(keyTime)
if added != None:
# now define the actual value of the key
key = added["key"]
key.SetValue(curve,someValue)
First you check if the track already exist. If not you can create the track yourself. When you have the track, you access it's curve and add the key. Finally you can set the key's value.
Best wishes,
Sebastian