Create a Key Curve without Record Button?
-
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?
-Scott
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 20/05/2011 at 06:55, xxxxxxxx wrote:
Hmm, I can instantiate a CTrack and insert CKeys into CCurves, but creating new Curves doesn't seem to be implemented ^^
I didn't do many stuff with animating and so on, so I actually don't know much about Curves and so on.
But it seems like, a Track does only hold one curve. And instantiating a Track does automatically create a curve inside of it. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 20/05/2011 at 08:53, xxxxxxxx wrote:
Creating a new track does not automatically create a new curve.
If it did. I wouldn't be using the record button to create one.
It just creates a new EMPTY track with no curves.From there we're stuck in a catch 22 situation.
We can't create any new keys. Because keys are children of curves. And the curve has to be there first before we can add any keys.
We have all these nice functions to create keys and tracks. And it seems that they forgot about adding a function to create a new curve so we could use them!?I wonder how you say " DOH! " in german?
-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 20/05/2011 at 09:28, xxxxxxxx wrote:
Yes, it does !
import c4d def main() : track = c4d.CTrack(op, 1) curve = track.GetCurve() print curve main()
But: how to assign this curve to a parameter of the Object ?
We use many anglicisms when expressing frustration ^^
Like sh*t or the f-word or damn.
Or do you mean it in sense of realisation ? Then it would be "ach, so !" e.g. ^^ -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 20/05/2011 at 10:10, xxxxxxxx wrote:
I meant that it does not create a curve.
Sure it's there in memory. But I don't see any functions to insert it into the empty track.It looks like they forgot to add that part when they were developing the timeline functions in C++.
Unless it's there... but it's not documented.-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/05/2011 at 02:37, xxxxxxxx wrote:
ScottA, I don't see any problems here. You can attach a track to an objects track list and add a new created key to the internal curve of this track. What do you miss here?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/05/2011 at 07:14, xxxxxxxx wrote:
Can you tell me how to attach the Track to a parameter of the Object ?
And can I do PLA Animation with Python ?Thanks, Nux
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/05/2011 at 07:42, xxxxxxxx wrote:
Originally posted by xxxxxxxx
ScottA, I don't see any problems here. You can attach a track to an objects track list and add a new created key to the internal curve of this track. What do you miss here?
Doh!
I didn't know you could do that.
I thought the curve had to exist in the scene before adding any keys. I didn't know you could do it all in memory.Here's an example in case anyone needs it:
import c4d from c4d import gui def main() : fps = doc.GetFps() frame = doc.GetMinTime().GetFrame(fps) #set min time 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) Ycurve = newYtrack.GetCurve() key1 = Ycurve.AddKey(c4d.BaseTime(frame, fps)) #Adds key at frame 0 key1.SetValue(Ycurve, 0) # Sets first key to a value of 0 c4d.EventAdd() if __name__=='__main__': main()
Thanks for the help,
-ScottA