THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/05/2011 at 19:12, xxxxxxxx wrote:
Someone was asking how to work with keys in another forum. And it dawned on me that I've never tried to create a curve from scratch. I've always used the Record Button in some fashion to add a new curve to an empty track. Which when you think about it is pretty silly.
I've looked in the python and C++ SDK's. But I don't see anything that creates a new curve on an empty track. So the method I'm using to create a new curve from scratch is pretty convoluted:
import c4d from c4d import gui def main() : obj = doc.GetActiveObject() newYtrack = c4d.CTrack(obj, c4d.DescID(c4d.DescLevel(c4d.ID_BASEOBJECT_POSITION, c4d.DTYPE_VECTOR, 0, ), c4d.DescLevel(c4d.VECTOR_Y, c4d.DTYPE_REAL, 0))) obj.InsertTrackSorted(newYtrack) objectType = c4d.DescLevel(c4d.ID_BASEOBJECT_REL_POSITION, c4d.DA_VECTOR, c4d.Obase) trackid = c4d.DescID(objectType, c4d.DescLevel(c4d.VECTOR_Y, c4d.DA_REAL, c4d.DA_VECTOR)) obj.SetKeyframeSelection(trackid,True) c4d.CallCommand(12410) #Record button only adds a key to the newYtrack. Because it has a KeyframeSelection on it c4d.EventAdd() if __name__=='__main__': main()
The last four lines of code are used to set up a condition where I can safely use the Record button to create the curve on the new track. And not affect anything else in the scene.
Is there a better (quicker) way to create a new curve. So I don't need to use the Record Button?