c4d.CKey¶
-
class
c4d.CKey¶ - Represents a key in the curve of a track which represent the animation of a parameter.Tangents are only guaranteed to be available for tracks of category
CTRACK_CATEGORY_VALUE. Tracks of the categoriesCTRACK_CATEGORY_DATAandCTRACK_CATEGORY_PLUGINmay contain tangent data or not. E.g., aBaseTimetrack will provide tangents for its keys, while a PLA track will not. Such tracks which do not provide tangent data will however not raise an error on attempting to retrieve a tangent for a key, but instead return the null-vector(0, 0, 0).
Parent Class:
Overview¶
Gets the time of the key. |
|
Gets the time component of the left tangent of the key.
|
|
Gets the time component of the right tangent of the key.
|
|
Gets the value of the key.
|
|
Gets the value component of the left tangent of the key.
|
|
Gets the value component of the right tangent of the key.
|
|
Sets the value of the key.
|
|
Sets the value component of the left tangent of the key.
|
|
Sets the value component of the right tangent of the key.
|
|
Sets the time of the key. |
|
Sets the time component of the left tangent of the key.
|
|
Sets the time component of the right tangent of the key.
|
|
Sets the interpolation type of the key. |
|
Returns the interpolation type of the key. |
|
Sets the quaternion interpolation type of the key. |
|
Gets the quaternion interpolation type of the key. |
|
Gets the track of the key. |
|
Gets the curve of the key. |
|
Flushes the data of the key. |
|
Sets the data of the key.
|
|
Gets the data of the key.
|
|
Gets a clone of the key. |
|
Gets the AutoTangent mode of the key. |
|
Sets the AutoTangent mode of the key. |
|
Sets Time Left and adjusts Value so the angle stays the same. |
|
Sets Time Right and adjusts Value so the angle stays the same. |
Members¶
-
CKey.GetTime(self)¶ Gets the time of the key.
- Return type
- Returns
The time.
-
CKey.GetTimeLeft(self)¶ - Gets the time component of the left tangent of the key.See class description for details on the availability of tangents.
- Return type
- Returns
The left time.
-
CKey.GetTimeRight(self)¶ - Gets the time component of the right tangent of the key.See class description for details on the availability of tangents.
- Return type
- Returns
The right time.
-
CKey.GetValue(self)¶ - Gets the value of the key.Used to read keys of tracks that are of category
CTRACK_CATEGORY_VALUE. This usually only does apply toDTYPE_REALandDTYPE_LONGtracks, other data types must be read withCKey.GetGeData(). An exception to that rule are tracks for data types that are composed out offloatvalues, like for examplec4d.Vectororc4d.Matrix. Here the type is being decomposed into multiple tracks of floating point values. E.g., for a vector into its three or four components and for a matrix first into its vectors and then each vector into its components. CallCTrack.GetTrackCategory()to determine the category of a track and therefore the method which has to be used to read data from its keys.See also
To read keys of tracks of the category
CTRACK_CATEGORY_DATA, including of typeDTYPE_BOOL, useCKey.GetGeData().- Return type
float
- Returns
The value.
-
CKey.GetValueLeft(self)¶ - Gets the value component of the left tangent of the key.See class description for details on the availability of tangents.
- Return type
float
- Returns
The value.
-
CKey.GetValueRight(self)¶ - Gets the value component of the right tangent of the key.See class description for details on the availability of tangents.
- Return type
float
- Returns
The value.
-
CKey.SetValue(self, seq, v)¶ - Sets the value of the key.Used to write keys of tracks that are of category
CTRACK_CATEGORY_VALUE. This usually only does apply toDTYPE_REALandDTYPE_LONGtracks, other data types must be written withCKey.SetGeData(). An exception to that rule are tracks for data types that are composed out offloatvalues, like for examplec4d.Vectororc4d.Matrix. Here the type is being decomposed into multiple tracks of floating point values. E.g., for a vector into its three or four components and for a matrix first into its vectors and then each vector into its components. CallCTrack.GetTrackCategory()to determine the category of a track and therefore the method which has to be used to write data into its keys.See also
To write keys of tracks of the category
CTRACK_CATEGORY_DATA, including of typeDTYPE_BOOL, useCKey.SetGeData().- Parameters
seq (c4d.CCurve) – The curve.
v (float) – The new value.
-
CKey.SetValueLeft(self, seq, v)¶ - Sets the value component of the left tangent of the key.See class description for details on the availability of tangents.
- Parameters
seq (c4d.CCurve) – The curve.
v (float) – The new value.
-
CKey.SetValueRight(self, seq, v)¶ - Sets the value component of the right tangent of the key.See class description for details on the availability of tangents.
- Parameters
seq (c4d.CCurve) – The curve.
v (float) – The new value.
-
CKey.SetTime(self, seq, t)¶ Sets the time of the key.
- Parameters
seq (c4d.CCurve) – The curve.
t (c4d.BaseTime) – The new time.
-
CKey.SetTimeLeft(self, seq, t)¶ - Sets the time component of the left tangent of the key.See class description for details on the availability of tangents.
- Parameters
seq (c4d.CCurve) – The curve.
t (c4d.BaseTime) – The time.
-
CKey.SetTimeRight(self, seq, t)¶ - Sets the time component of the right tangent of the key.See class description for details on the availability of tangents.
- Parameters
seq (c4d.CCurve) – The curve.
t (c4d.BaseTime) – The time.
-
CKey.SetInterpolation(self, seq, inter)¶ Sets the interpolation type of the key.
- Parameters
seq (c4d.CCurve) – The curve.
int –
The new interpolation type:
CINTERPOLATION_SPLINE
Spline.
CINTERPOLATION_LINEAR
Linear
CINTERPOLATION_STEP
Step.
-
CKey.GetInterpolation(self)¶ Returns the interpolation type of the key.
- Return type
int
- Returns
The interpolation type:
CINTERPOLATION_SPLINE
Spline.
CINTERPOLATION_LINEAR
Linear
CINTERPOLATION_STEP
Step.
-
CKey.SetQuatInterpolation(self, seq, inter, bUndo=True)¶ Sets the quaternion interpolation type of the key.
New in version R18.020.
Note
Keys at the same time on other component curve will be modified.
- Parameters
seq (c4d.CCurve) – The curve the key belongs to.
inter (int) –
The quaternion interpolation type to set:
ROTATIONINTERPOLATION_QUATERNION_SLERP
Quaternion Spherical LERP Interpolation (Linear).
ROTATIONINTERPOLATION_QUATERNION_CUBIC
Quaternion Smooth Cubic Interpolation (Formerly known as Losch).
bUndo (bool) –
True to add the 3 rotation keys in the undo system.The caller has to to manage start/end of undo actions withBaseDocument.StartUndo()/EndUndo().
-
CKey.GetQuatInterpolation(self)¶ Gets the quaternion interpolation type of the key.
New in version R18.020.
- Return type
int
- Returns
The quaternion interpolation type:
ROTATIONINTERPOLATION_QUATERNION_SLERP
Quaternion Spherical LERP Interpolation (Linear).
ROTATIONINTERPOLATION_QUATERNION_CUBIC
Quaternion Smooth Cubic Interpolation (Formerly known as Losch).
-
CKey.GetTrack(self)¶ Gets the track of the key.
- Return type
- Returns
The track.
-
CKey.GetCurve(self)¶ Gets the curve of the key.
- Return type
- Returns
The curve.
-
CKey.FlushData(self)¶ Flushes the data of the key.
-
CKey.SetGeData(self, seq, d)¶ - Sets the data of the key.Used to write keys of tracks that are of category
CTRACK_CATEGORY_DATA. This usually does apply to tracks that neither storeDTYPE_REALandDTYPE_LONGdata, and those data types must be written withCKey.SetValue(). An exception to that rule are tracks for data types that are composed out offloatvalues, like for examplec4d.Vectororc4d.Matrix. Here the type is being decomposed into multiple tracks of floating point values. E.g., for a vector into its three or four components and for a matrix first into its vectors and then each vector into its components. CallCTrack.GetTrackCategory()to determine the category of a track and therefore the method which has to be used to write data into its keys. See the example below for how to write a boolean key value with this method.# Get the first material of the document and its first track. mat = doc.GetFirstMaterial() if mat is None: raise RuntimeError("No material found.") track = mat.GetFirstCTrack() if track is None: raise RuntimeError("Material has no tracks.") # Bail when this first track is not for the boolean "use color" parameter # of the material. if track.GetDescriptionID()[0].id != c4d.MATERIAL_USE_COLOR: raise RuntimeError("'Use-Color' track not found") # Get the curve of the track and its first key. curve = track.GetCurve(c4d.CCURVE_CURVE) if curve.GetKeyCount() < 1: raise RuntimeError("Curve has no keys.") key = curve.GetKey(0) # Print the current value of the boolean key and then set it to `True`. print (key.GetGeData()) key.SetGeData(curve, True) # Push an update event to Cinema 4D. c4d.EventAdd()
See also
To write keys of tracks of the category
CTRACK_CATEGORY_VALUE, useCKey.SetValue().- Parameters
seq (c4d.CCurve) – The curve.
d (any) – The data.
-
CKey.GetGeData(self)¶ - Gets the data of the key.Used to read keys of tracks that are of category
CTRACK_CATEGORY_DATA. This usually does apply to tracks that neither storeDTYPE_REALandDTYPE_LONGdata, those data types must be read withCKey.GetValue(). An exception to that rule are tracks for data types that are composed out offloatvalues, like for examplec4d.Vectororc4d.Matrix. Here the type is being decomposed into multiple tracks of floating point values. E.g., for a vector into its three or four components and for a matrix first into its vectors and then each vector into its components. CallCTrack.GetTrackCategory()to determine the category of a track and therefore the method which has to be used to read data from its keys. See the example below for how to read complex data out of a key. The compilation of the returnedc4d.BaseContainerdepends on the described data type. Seec4d.CustomDataTypefor an overview of the custom data types exposed to Python.# This is a PLA track, we get its curve and iterate over all keys. if ctrack.CheckType(c4d.CTpla): curve = ctrack.GetCurve(c4d.CCURVE_CURVE) for i in range(curve.GetKeyCount()): ckey = curve.GetKey(i) # We retrieve the key data with GetGeData which usually returns # a BaseContainer(). data = ckey.GetGeData() if not isinstance(data, c4d.BaseContainer): RuntimeError("Failed to retrieve PLA data.") print (data[c4d.CK_PLA_DATA])
See also
To read keys of tracks of the category
CTRACK_CATEGORY_VALUE, useCKey.GetValue().- Return type
Any
- Returns
The data, depends on the key.
-
CKey.GetClone(self, trans=None)¶ Gets a clone of the key.
- Parameters
trans (Optional[c4d.AliasTrans]) –
New in version R17.032: An optional alias translator for the operation.
- Return type
- Returns
The cloned key.
-
CKey.GetAutomaticTangentMode(self)¶ Gets the AutoTangent mode of the key.
New in version R17.048.
- Return type
int
- Returns
The AutoTangent mode:
CAUTOMODE_CLASSIC
AutoTangent first implementation.
CAUTOMODE_FIXEDSLOPE
AutoTangent with fixed slope for given time.
-
CKey.SetAutomaticTangentMode(self, seq, autoMode)¶ Sets the AutoTangent mode of the key.
New in version R17.048.
- Parameters
seq (c4d.CCurve) – The curve the key belongs to.
autoMode (int) –
The AutoTangent mode to set:
CAUTOMODE_CLASSIC
AutoTangent first implementation.
CAUTOMODE_FIXEDSLOPE
AutoTangent with fixed slope for given time.
-
CKey.SetTimeLeftAdjustValue(self, seq, t)¶ Sets Time Left and adjusts Value so the angle stays the same.
New in version R17.048.
- Parameters
seq (c4d.CCurve) – The curve the key belongs to.
t (c4d.BaseTime) – The Time Left to set.
- Return type
bool
- Returns
True if successful. False if current Time Left is smaller than FLT_MIN and Value is not Zero (angle cannot stay the same).
-
CKey.SetTimeRightAdjustValue(self, seq, t)¶ Sets Time Right and adjusts Value so the angle stays the same.
New in version R17.048.
- Parameters
seq (c4d.CCurve) – The curve the key belongs to.
t (c4d.BaseTime) – The Time Right to set.
- Return type
bool
- Returns
True if successful. False if current Time Right is smaller than FLT_MIN and Value is not Zero (angle cannot stay the same).