57 #include "../generic/python_utildefines.h"
63 const char *error_prefix,
65 const char **r_path_full,
67 bool *r_path_no_validate)
75 PyExc_TypeError,
"%.200s this struct has no data, can't be animated", error_prefix);
85 else if (path_index != -1) {
86 PyErr_Format(PyExc_ValueError,
87 "%.200s path includes index, must be a separate argument",
93 PyErr_Format(PyExc_ValueError,
"%.200s path spans ID blocks", error_prefix, path);
103 if (r_path_no_validate) {
104 *r_path_no_validate =
true;
107 PyErr_Format(PyExc_TypeError,
"%.200s property \"%s\" not found", error_prefix, path);
111 if (r_path_no_validate) {
116 PyErr_Format(PyExc_TypeError,
"%.200s property \"%s\" not animatable", error_prefix, path);
121 if ((*r_index) == -1) {
125 PyErr_Format(PyExc_TypeError,
126 "%.200s index %d was given while property \"%s\" is not an array",
135 if ((*r_index) < -1 || (*r_index) >= array_len) {
136 PyErr_Format(PyExc_TypeError,
137 "%.200s index out of range \"%s\", given %d, array length is %d",
153 if (*r_path_full ==
NULL) {
154 PyErr_Format(PyExc_TypeError,
"%.200s could not make path to \"%s\"", error_prefix, path);
163 const char *error_prefix,
165 const char **r_path_full,
175 const char *error_prefix,
177 const char **r_path_full)
186 if (path_prefix ==
NULL) {
187 PyErr_Format(PyExc_TypeError,
188 "%.200s could not make path for type %s",
206 const char *error_prefix,
208 const char **r_path_full,
211 bool path_unresolved =
false;
213 ptr, error_prefix, path, r_path_full, r_index, &path_unresolved) == -1) {
214 if (path_unresolved ==
true) {
230 const char *parse_str,
231 const char *error_prefix,
233 const char **r_path_full,
236 const char **r_group_name,
239 static const char *kwlist[] = {
"data_path",
"index",
"frame",
"group",
"options",
NULL};
240 PyObject *pyoptions =
NULL;
244 if (!PyArg_ParseTupleAndKeywords(args,
261 if (*r_cfra == FLT_MAX) {
280 ".. method:: keyframe_insert(data_path, index=-1, frame=bpy.context.scene.frame_current, "
281 "group=\"\", options=set())\n"
283 " Insert a keyframe on the property given, adding fcurves and animation data when "
286 " :arg data_path: path to the property to key, analogous to the fcurve's data path.\n"
287 " :type data_path: string\n"
288 " :arg index: array index of the property to key.\n"
289 " Defaults to -1 which will key all indices or a single channel if the property is not "
291 " :type index: int\n"
292 " :arg frame: The frame on which the keyframe is inserted, defaulting to the current "
294 " :type frame: float\n"
295 " :arg group: The name of the group the F-Curve should be added to if it doesn't exist "
297 " :type group: str\n"
298 " :arg options: Optional set of flags:\n"
300 " - ``INSERTKEY_NEEDED`` Only insert keyframes where they're needed in the relevant "
302 " - ``INSERTKEY_VISUAL`` Insert keyframes based on 'visual transforms'.\n"
303 " - ``INSERTKEY_XYZ_TO_RGB`` Color for newly added transformation F-Curves (Location, "
304 "Rotation, Scale) is based on the transform axis.\n"
305 " - ``INSERTKEY_REPLACE`` Only replace already existing keyframes.\n"
306 " - ``INSERTKEY_AVAILABLE`` Only insert into already existing F-Curves.\n"
307 " - ``INSERTKEY_CYCLE_AWARE`` Take cyclic extrapolation into account "
308 "(Cycle-Aware Keying option).\n"
310 " :return: Success of keyframe insertion.\n"
311 " :rtype: boolean\n";
315 const char *path_full =
NULL;
317 float cfra = FLT_MAX;
318 const char *group_name =
NULL;
327 "s|ifsO!:bpy_struct.keyframe_insert()",
328 "bpy_struct.keyframe_insert()",
359 const char *prop_name;
364 prop_name = strrchr(path_full,
'.');
365 if ((prop_name >= path_full) && (prop_name + 1 < path_full + strlen(path_full))) {
373 &reports,
ptr, prop, fcu, &anim_eval_context, keytype,
NULL,
options);
384 return PyBool_FromLong(
result);
387 ID *
id =
self->ptr.owner_id;
411 return PyBool_FromLong(
result);
415 ".. method:: keyframe_delete(data_path, index=-1, frame=bpy.context.scene.frame_current, "
418 " Remove a keyframe from this properties fcurve.\n"
420 " :arg data_path: path to the property to remove a key, analogous to the fcurve's data "
422 " :type data_path: string\n"
423 " :arg index: array index of the property to remove a key. Defaults to -1 removing all "
424 "indices or a single channel if the property is not an array.\n"
425 " :type index: int\n"
426 " :arg frame: The frame on which the keyframe is deleted, defaulting to the current frame.\n"
427 " :type frame: float\n"
428 " :arg group: The name of the group the F-Curve should be added to if it doesn't exist "
430 " :type group: str\n"
431 " :return: Success of keyframe deletion.\n"
432 " :rtype: boolean\n";
436 const char *path_full =
NULL;
438 float cfra = FLT_MAX;
439 const char *group_name =
NULL;
446 "s|ifsO!:bpy_struct.keyframe_delete()",
447 "bpy_struct.keyframe_insert()",
465 const char *prop_name;
470 prop_name = strrchr(path_full,
'.');
471 if ((prop_name >= path_full) && (prop_name + 1 < path_full + strlen(path_full))) {
487 "Not deleting keyframe for locked F-Curve for NLA Strip influence on %s - %s '%s'",
518 return PyBool_FromLong(
result);
534 return PyBool_FromLong(
result);
538 ".. method:: driver_add(path, index=-1)\n"
540 " Adds driver(s) to the given property\n"
542 " :arg path: path to the property to drive, analogous to the fcurve's data path.\n"
543 " :type path: string\n"
544 " :arg index: array index of the property drive. Defaults to -1 for all indices or a single "
545 "channel if the property is not an array.\n"
546 " :type index: int\n"
547 " :return: The driver(s) added.\n"
548 " :rtype: :class:`bpy.types.FCurve` or list if index is -1 with an array property.\n";
551 const char *path, *path_full;
556 if (!PyArg_ParseTuple(args,
"s|i:driver_add", &path, &index)) {
561 &
self->ptr,
"bpy_struct.driver_add():", path, &path_full, &index) == -1) {
583 ID *
id =
self->ptr.owner_id;
609 PyErr_SetString(PyExc_TypeError,
610 "bpy_struct.driver_add(): failed because of an internal error");
620 ".. method:: driver_remove(path, index=-1)\n"
622 " Remove driver(s) from the given property\n"
624 " :arg path: path to the property to drive, analogous to the fcurve's data path.\n"
625 " :type path: string\n"
626 " :arg index: array index of the property drive. Defaults to -1 for all indices or a single "
627 "channel if the property is not an array.\n"
628 " :type index: int\n"
629 " :return: Success of driver removal.\n"
630 " :rtype: boolean\n";
633 const char *path, *path_full;
638 if (!PyArg_ParseTuple(args,
"s|i:driver_remove", &path, &index)) {
643 &
self->ptr,
"bpy_struct.driver_remove():", path, &path_full, &index) == -1) {
654 if (path != path_full) {
666 return PyBool_FromLong(
result);
struct AnimData * BKE_animdata_from_id(struct ID *id)
AnimationEvalContext BKE_animsys_eval_context_construct(struct Depsgraph *depsgraph, float eval_time)
struct Scene * CTX_data_scene(const bContext *C)
struct Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
struct Main * CTX_data_main(const bContext *C)
bool BKE_fcurve_is_protected(struct FCurve *fcu)
struct FCurve * BKE_fcurve_find(ListBase *list, const char rna_path[], const int array_index)
int BKE_fcurve_bezt_binarysearch_index(struct BezTriple array[], float frame, int arraylen, bool *r_replace)
const char * BKE_idtype_idcode_to_name(const short idcode)
bool BKE_id_is_in_global_main(struct ID *id)
void BKE_reportf(ReportList *reports, ReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_reports_init(ReportList *reports, int flag)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
#define BLI_string_joinN(...)
#define BLI_string_join_by_sep_charN(sep,...)
struct Depsgraph Depsgraph
void DEG_relations_tag_update(struct Main *bmain)
@ CREATEDRIVER_WITH_FMODIFIER
Read Guarded memory(de)allocation.
short BPy_reports_to_error(ReportList *reports, PyObject *exception, const bool clear)
struct bContext * BPY_context_get(void)
int pyrna_set_to_enum_bitfield(const EnumPropertyItem *items, PyObject *value, int *r_value, const char *error_prefix)
PyObject * pyrna_struct_CreatePyObject(PointerRNA *ptr)
#define PYRNA_STRUCT_CHECK_OBJ(obj)
PyObject * pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyObject *kw)
char pyrna_struct_driver_add_doc[]
char pyrna_struct_keyframe_insert_doc[]
static int pyrna_struct_anim_args_parse_no_resolve(PointerRNA *ptr, const char *error_prefix, const char *path, const char **r_path_full)
PyObject * pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyObject *kw)
static int pyrna_struct_anim_args_parse_ex(PointerRNA *ptr, const char *error_prefix, const char *path, const char **r_path_full, int *r_index, bool *r_path_no_validate)
static int pyrna_struct_keyframe_parse(PointerRNA *ptr, PyObject *args, PyObject *kw, const char *parse_str, const char *error_prefix, const char **r_path_full, int *r_index, float *r_cfra, const char **r_group_name, int *r_options)
char pyrna_struct_driver_remove_doc[]
static int pyrna_struct_anim_args_parse_no_resolve_fallback(PointerRNA *ptr, const char *error_prefix, const char *path, const char **r_path_full, int *r_index)
char pyrna_struct_keyframe_delete_doc[]
PyObject * pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefix, const char *path, const char **r_path_full, int *r_index)
PyObject * pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
CCL_NAMESPACE_BEGIN struct Options options
const Depsgraph * depsgraph
bool ANIM_remove_driver(ReportList *UNUSED(reports), ID *id, const char rna_path[], int array_index, short UNUSED(flag))
int ANIM_add_driver(ReportList *reports, ID *id, const char rna_path[], int array_index, short flag, int type)
void delete_fcurve_key(FCurve *fcu, int index, bool do_recalc)
int delete_keyframe(Main *bmain, ReportList *reports, ID *id, bAction *act, const char rna_path[], int array_index, float cfra)
bool insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, const AnimationEvalContext *anim_eval_context, eBezTriple_KeyframeType keytype, struct NlaKeyframingContext *nla_context, eInsertKeyFlags flag)
int insert_keyframe(Main *bmain, ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, const AnimationEvalContext *anim_eval_context, eBezTriple_KeyframeType keytype, ListBase *nla_cache, eInsertKeyFlags flag)
void(* MEM_freeN)(void *vmemh)
const char * RNA_struct_identifier(const StructRNA *type)
bool RNA_property_array_check(PropertyRNA *prop)
bool RNA_property_animateable(PointerRNA *ptr, PropertyRNA *prop)
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
bool RNA_struct_is_ID(const StructRNA *type)
const char * RNA_property_identifier(const PropertyRNA *prop)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
char * RNA_path_from_ID_to_property(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_path_resolve_property_full(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
char * RNA_path_from_ID_to_struct(PointerRNA *ptr)
const EnumPropertyItem rna_enum_keying_flag_items_api[]
struct SELECTID_Context context
void WM_event_add_notifier(const bContext *C, uint type, void *reference)