[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24184] trunk/blender/source/blender: - setting the active object in rna works properly now (notifiers added)
Campbell Barton
ideasman42 at gmail.com
Fri Oct 30 18:23:40 CET 2009
Revision: 24184
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24184
Author: campbellbarton
Date: 2009-10-30 18:23:40 +0100 (Fri, 30 Oct 2009)
Log Message:
-----------
- setting the active object in rna works properly now (notifiers added)
- adding keyframes now works for bones and other data types (not just ID types)
# Add a pose bone keyframe
bpy.data.objects['Armature.001'].pose.pose_channels["Hip"].keyframe_insert("location")
# Add an object keyframe (worked before)
bpy.data.objects['Armature.001'].keyframe_insert("location")
Modified Paths:
--------------
trunk/blender/source/blender/makesrna/intern/rna_scene.c
trunk/blender/source/blender/python/intern/bpy_rna.c
Modified: trunk/blender/source/blender/makesrna/intern/rna_scene.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_scene.c 2009-10-30 17:15:11 UTC (rev 24183)
+++ trunk/blender/source/blender/makesrna/intern/rna_scene.c 2009-10-30 17:23:40 UTC (rev 24184)
@@ -2211,8 +2211,10 @@
RNA_def_property_pointer_funcs(prop, "rna_Scene_active_object_get", "rna_Scene_active_object_set", NULL);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Object", "Object to use as projector transform.");
+ /* Could call: ED_base_object_activate(C, scene->basact);
+ * but would be a bad level call and it seems the notifier is enough */
+ RNA_def_property_update(prop, NC_SCENE|ND_OB_ACTIVE, NULL);
-
prop= RNA_def_property(srna, "world", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "World", "World used for rendering the scene.");
Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c 2009-10-30 17:15:11 UTC (rev 24183)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c 2009-10-30 17:23:40 UTC (rev 24184)
@@ -1154,19 +1154,43 @@
static PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA * self, PyObject *args)
{
- char *path;
+ char *path, *path_full;
int index= 0;
float cfra = CTX_data_scene(BPy_GetContext())->r.cfra;
+ PropertyRNA *prop;
+ PyObject *result;
- if(!RNA_struct_is_ID(self->ptr.type)) {
- PyErr_SetString( PyExc_TypeError, "StructRNA - keyframe_insert only for ID type");
+ if (!PyArg_ParseTuple(args, "s|if:keyframe_insert", &path, &index, &cfra))
return NULL;
+
+ if (self->ptr.data==NULL) {
+ PyErr_Format( PyExc_TypeError, "keyframe_insert, this struct has no data, cant be animated", path);
+ return NULL;
}
- if (!PyArg_ParseTuple(args, "s|if:keyframe_insert", &path, &index, &cfra))
+ prop = RNA_struct_find_property(&self->ptr, path);
+
+ if (prop==NULL) {
+ PyErr_Format( PyExc_TypeError, "keyframe_insert, property \"%s\" not found", path);
return NULL;
+ }
- return PyBool_FromLong( insert_keyframe((ID *)self->ptr.data, NULL, NULL, path, index, cfra, 0));
+ if (!RNA_property_animateable(&self->ptr, prop)) {
+ PyErr_Format( PyExc_TypeError, "keyframe_insert, property \"%s\" not animatable", path);
+ return NULL;
+ }
+
+ path_full= RNA_path_from_ID_to_property(&self->ptr, prop);
+
+ if (path_full==NULL) {
+ PyErr_Format( PyExc_TypeError, "keyframe_insert, could not make path to \"%s\"", path);
+ return NULL;
+ }
+
+ result= PyBool_FromLong( insert_keyframe((ID *)self->ptr.id.data, NULL, NULL, path_full, index, cfra, 0));
+ MEM_freeN(path_full);
+
+ return result;
}
static PyObject *pyrna_struct_is_property_set(BPy_StructRNA * self, PyObject *args)
@@ -1366,10 +1390,11 @@
PropertyRNA *prop = RNA_struct_find_property(&self->ptr, name);
if (prop==NULL) {
+ // XXX - This currently allows anything to be assigned to an rna prop, need to see how this should be used
+ // but for now it makes porting scripts confusing since it fails silently.
if (!BPy_StructRNA_CheckExact(self) && PyObject_GenericSetAttr((PyObject *)self, pyname, value) >= 0) {
return 0;
- }
- else {
+ } else {
PyErr_Format( PyExc_AttributeError, "StructRNA - Attribute \"%.200s\" not found", name);
return -1;
}
More information about the Bf-blender-cvs
mailing list