visualride
06-19-2012, 09:42 PM
I've been struggling with trying to set non-standard keyframes(they don't change with the record button) within Cinema 4D R12 on OSX. I've written code that I thought would work, but didn't.
This code does create an 'Enabled' curve and adds a key, but it does not add the correct amount (I want '1' -Enabled), and the key is strange because it isn't showing up as red, or actually keyframed, but the key is showing in the timeline. The "keyy.SetValue(crv,1)" line doesn't seem to be working.
Since this is R12 I don't have the following classes to use: FindCTrack, FillKey, or SetGeData among others. Anyone have an idea?
Note: This is a similar post to one that I posted a few weeks ago with some great feedback, but I still haven't gotten it to work yet.
import c4d, math
from c4d import gui
#Welcome to the world of Python
def main():
myDoc = c4d.documents.GetActiveDocument()
Selected = doc.GetActiveObjects(0)
fps = myDoc.GetFps()
if len(Selected)>0:
for ListOb in Selected:
visE = c4d.CTrack(ListOb, c4d.DescID(c4d.ID_BASEOBJECT_GENERATOR_FLAG))
ListOb.InsertTrackSorted(visE)
#ListOb[c4d.ID_BASEOBJECT_GENERATOR_FLAG] = 1
t = doc.GetTime().Get()
crv = visE.GetCurve()
keyy = crv.AddKey(c4d.BaseTime(t))['key']
keyy.SetValue(crv,1)
c4d.EventAdd()
else:
gui.MessageDialog('You must select an Object first!')
if __name__=='__main__':
main()
This code does create an 'Enabled' curve and adds a key, but it does not add the correct amount (I want '1' -Enabled), and the key is strange because it isn't showing up as red, or actually keyframed, but the key is showing in the timeline. The "keyy.SetValue(crv,1)" line doesn't seem to be working.
Since this is R12 I don't have the following classes to use: FindCTrack, FillKey, or SetGeData among others. Anyone have an idea?
Note: This is a similar post to one that I posted a few weeks ago with some great feedback, but I still haven't gotten it to work yet.
import c4d, math
from c4d import gui
#Welcome to the world of Python
def main():
myDoc = c4d.documents.GetActiveDocument()
Selected = doc.GetActiveObjects(0)
fps = myDoc.GetFps()
if len(Selected)>0:
for ListOb in Selected:
visE = c4d.CTrack(ListOb, c4d.DescID(c4d.ID_BASEOBJECT_GENERATOR_FLAG))
ListOb.InsertTrackSorted(visE)
#ListOb[c4d.ID_BASEOBJECT_GENERATOR_FLAG] = 1
t = doc.GetTime().Get()
crv = visE.GetCurve()
keyy = crv.AddKey(c4d.BaseTime(t))['key']
keyy.SetValue(crv,1)
c4d.EventAdd()
else:
gui.MessageDialog('You must select an Object first!')
if __name__=='__main__':
main()
