示例#1
0
PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyObject *kw)
{
	/* args, pyrna_struct_keyframe_parse handles these */
	const char *path_full = NULL;
	int index = -1;
	float cfra = FLT_MAX;
	const char *group_name = NULL;

	PYRNA_STRUCT_CHECK_OBJ(self);

	if (pyrna_struct_keyframe_parse(&self->ptr, args, kw,
	                                "s|ifsO!:bpy_struct.keyframe_delete()",
	                                "bpy_struct.keyframe_insert()",
	                                &path_full, &index, &cfra, &group_name, NULL) == -1)
	{
		return NULL;
	}
	else {
		short result;
		ReportList reports;

		BKE_reports_init(&reports, RPT_STORE);

		result = delete_keyframe(&reports, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, 0);
		MEM_freeN((void *)path_full);

		if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
			return NULL;

		return PyBool_FromLong(result);
	}

}
PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyObject *kw)
{
	/* args, pyrna_struct_keyframe_parse handles these */
	const char *path_full = NULL;
	int index = -1;
	float cfra = FLT_MAX;
	const char *group_name = NULL;
	char keytype = BEZT_KEYTYPE_KEYFRAME; /* XXX: Expose this as a one-off option... */
	int options = 0;

	PYRNA_STRUCT_CHECK_OBJ(self);

	if (pyrna_struct_keyframe_parse(&self->ptr, args, kw,
	                                "s|ifsO!:bpy_struct.keyframe_insert()", "bpy_struct.keyframe_insert()",
	                                &path_full, &index, &cfra, &group_name, &options) == -1)
	{
		return NULL;
	}
	else {
		short result;
		ReportList reports;

		BKE_reports_init(&reports, RPT_STORE);

		result = insert_keyframe(&reports, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, keytype, options);
		MEM_freeN((void *)path_full);

		if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
			return NULL;

		return PyBool_FromLong(result);
	}
}