Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/python/intern/bpy_rna.c')
-rw-r--r--source/blender/python/intern/bpy_rna.c375
1 files changed, 288 insertions, 87 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 4792d284ca7..89782978c85 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -1,4 +1,3 @@
-
/**
* $Id$
*
@@ -51,7 +50,7 @@
#define USE_MATHUTILS
#ifdef USE_MATHUTILS
-#include "../generic/Mathutils.h" /* so we can have mathutils callbacks */
+#include "../generic/mathutils.h" /* so we can have mathutils callbacks */
#include "../generic/IDProp.h" /* for IDprop lookups */
@@ -67,6 +66,7 @@ static int mathutils_rna_array_cb_index= -1; /* index for our callbacks */
#define MATHUTILS_CB_SUBTYPE_EUL 0
#define MATHUTILS_CB_SUBTYPE_VEC 1
#define MATHUTILS_CB_SUBTYPE_QUAT 2
+#define MATHUTILS_CB_SUBTYPE_COLOR 0
static int mathutils_rna_generic_check(BPy_PropertyRNA *self)
{
@@ -84,9 +84,19 @@ static int mathutils_rna_vector_get(BPy_PropertyRNA *self, int subtype, float *v
static int mathutils_rna_vector_set(BPy_PropertyRNA *self, int subtype, float *vec_to)
{
+ float min, max;
if(self->prop==NULL)
return 0;
- /* TODO, clamp */
+
+ RNA_property_float_range(&self->ptr, self->prop, &min, &max);
+
+ if(min != FLT_MIN || max != FLT_MAX) {
+ int i, len= RNA_property_array_length(&self->ptr, self->prop);
+ for(i=0; i<len; i++) {
+ CLAMP(vec_to[i], min, max);
+ }
+ }
+
RNA_property_float_set_array(&self->ptr, self->prop, vec_to);
RNA_property_update(BPy_GetContext(), &self->ptr, self->prop);
return 1;
@@ -237,8 +247,8 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
}
else {
PyObject *eul_cb= newEulerObject_cb(ret, 0, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_EUL); // TODO, get order from RNA
- Py_DECREF(ret); /* the matrix owns now */
- ret= eul_cb; /* return the matrix instead */
+ Py_DECREF(ret); /* the euler owns now */
+ ret= eul_cb; /* return the euler instead */
}
}
else if (len==4) {
@@ -248,11 +258,23 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
}
else {
PyObject *quat_cb= newQuaternionObject_cb(ret, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_QUAT);
- Py_DECREF(ret); /* the matrix owns now */
- ret= quat_cb; /* return the matrix instead */
+ Py_DECREF(ret); /* the quat owns now */
+ ret= quat_cb; /* return the quat instead */
}
}
break;
+ case PROP_COLOR:
+ if(len==3) { /* color */
+ if(is_thick) {
+ ret= newColorObject(NULL, Py_NEW, NULL); // TODO, get order from RNA
+ RNA_property_float_get_array(ptr, prop, ((ColorObject *)ret)->col);
+ }
+ else {
+ PyObject *col_cb= newColorObject_cb(ret, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_COLOR);
+ Py_DECREF(ret); /* the color owns now */
+ ret= col_cb; /* return the color instead */
+ }
+ }
default:
break;
}
@@ -1077,6 +1099,9 @@ static int pyrna_py_to_prop_index(BPy_PropertyRNA *self, int index, PyObject *va
break;
}
}
+
+ /* Run rna property functions */
+ RNA_property_update(BPy_GetContext(), ptr, prop);
return ret;
}
@@ -1610,6 +1635,16 @@ static PyMappingMethods pyrna_struct_as_mapping = {
( objobjargproc ) pyrna_struct_ass_subscript, /* mp_ass_subscript */
};
+static char pyrna_struct_keys_doc[] =
+".. method:: keys()\n"
+"\n"
+" Returns the keys of this objects custom properties (matches pythons dictionary function of the same name).\n"
+"\n"
+" :return: custom property keys.\n"
+" :rtype: list of strings\n"
+"\n"
+" .. note:: Only :class:`ID`, :class:`Bone` and :class:`PoseBone` classes support custom properties.\n";
+
static PyObject *pyrna_struct_keys(BPy_PropertyRNA *self)
{
IDProperty *group;
@@ -1627,6 +1662,16 @@ static PyObject *pyrna_struct_keys(BPy_PropertyRNA *self)
return BPy_Wrap_GetKeys(group);
}
+static char pyrna_struct_items_doc[] =
+".. method:: items()\n"
+"\n"
+" Returns the items of this objects custom properties (matches pythons dictionary function of the same name).\n"
+"\n"
+" :return: custom property key, value pairs.\n"
+" :rtype: list of key, value tuples\n"
+"\n"
+" .. note:: Only :class:`ID`, :class:`Bone` and :class:`PoseBone` classes support custom properties.\n";
+
static PyObject *pyrna_struct_items(BPy_PropertyRNA *self)
{
IDProperty *group;
@@ -1644,6 +1689,15 @@ static PyObject *pyrna_struct_items(BPy_PropertyRNA *self)
return BPy_Wrap_GetItems(self->ptr.id.data, group);
}
+static char pyrna_struct_values_doc[] =
+".. method:: values()\n"
+"\n"
+" Returns the values of this objects custom properties (matches pythons dictionary function of the same name).\n"
+"\n"
+" :return: custom property values.\n"
+" :rtype: list\n"
+"\n"
+" .. note:: Only :class:`ID`, :class:`Bone` and :class:`PoseBone` classes support custom properties.\n";
static PyObject *pyrna_struct_values(BPy_PropertyRNA *self)
{
@@ -1662,36 +1716,46 @@ static PyObject *pyrna_struct_values(BPy_PropertyRNA *self)
return BPy_Wrap_GetValues(self->ptr.id.data, group);
}
-/* internal use for insert and delete */
-int pyrna_struct_keyframe_parse(PointerRNA *ptr, PyObject *args, char *error_prefix,
- char **path_full, int *index, float *cfra) /* return values */
+/* for keyframes and drivers */
+static int pyrna_struct_anim_args_parse(PointerRNA *ptr, char *error_prefix, char *path,
+ char **path_full, int *index)
{
- char *path;
PropertyRNA *prop;
- int array_len;
-
- if (!PyArg_ParseTuple(args, "s|if", &path, index, cfra)) {
- PyErr_Format(PyExc_TypeError, "%.200s expected a string and optionally an int and float arguments", error_prefix);
- return -1;
- }
-
+
if (ptr->data==NULL) {
PyErr_Format(PyExc_TypeError, "%.200s this struct has no data, can't be animated", error_prefix);
return -1;
}
-
+
prop = RNA_struct_find_property(ptr, path);
-
+
if (prop==NULL) {
PyErr_Format( PyExc_TypeError, "%.200s property \"%s\" not found", error_prefix, path);
return -1;
}
if (!RNA_property_animateable(ptr, prop)) {
- PyErr_Format( PyExc_TypeError, "%.200s property \"%s\" not animatable", error_prefix, path);
+ PyErr_Format(PyExc_TypeError, "%.200s property \"%s\" not animatable", error_prefix, path);
return -1;
}
+ if(RNA_property_array_check(ptr, prop) == 0) {
+ if((*index) == -1) {
+ *index= 0;
+ }
+ else {
+ PyErr_Format(PyExc_TypeError, "%.200s index %d was given while property \"%s\" is not an array", error_prefix, *index, path);
+ return -1;
+ }
+ }
+ else {
+ int array_len= RNA_property_array_length(ptr, prop);
+ if((*index) < -1 || (*index) >= array_len) {
+ PyErr_Format( PyExc_TypeError, "%.200s index out of range \"%s\", given %d, array length is %d", error_prefix, path, *index, array_len);
+ return -1;
+ }
+ }
+
*path_full= RNA_path_from_ID_to_property(ptr, prop);
if (*path_full==NULL) {
@@ -1699,18 +1763,45 @@ int pyrna_struct_keyframe_parse(PointerRNA *ptr, PyObject *args, char *error_pre
return -1;
}
- array_len= RNA_property_array_length(ptr, prop);
- if((*index) != -1 && (*index) >= array_len) {
- PyErr_Format( PyExc_TypeError, "%.200s index out of range \"%s\", given %d, array length is %d", error_prefix, path, *index, array_len);
+ return 0;
+}
+
+/* internal use for insert and delete */
+static int pyrna_struct_keyframe_parse(PointerRNA *ptr, PyObject *args, char *error_prefix,
+ char **path_full, int *index, float *cfra, char **group_name) /* return values */
+{
+ char *path;
+
+ if (!PyArg_ParseTuple(args, "s|ifs", &path, index, cfra, group_name)) {
+ PyErr_Format(PyExc_TypeError, "%.200s expected a string and optionally an int, float, and string arguments", error_prefix);
return -1;
}
+ if(pyrna_struct_anim_args_parse(ptr, error_prefix, path, path_full, index) < 0)
+ return -1;
+
if(*cfra==FLT_MAX)
*cfra= CTX_data_scene(BPy_GetContext())->r.cfra;
return 0; /* success */
}
+static char pyrna_struct_keyframe_insert_doc[] =
+".. method:: keyframe_insert(path, index=-1, frame=bpy.context.scene.frame_current)\n"
+"\n"
+" Insert a keyframe on the property given, adding fcurves and animation data when necessary.\n"
+"\n"
+" :arg path: path to the property to key, analogous to the fcurve's data path.\n"
+" :type path: string\n"
+" :arg index: array index of the property to key. Defaults to -1 which will key all indicies or a single channel if the property is not an array.\n"
+" :type index: int\n"
+" :arg frame: The frame on which the keyframe is inserted, defaulting to the current frame.\n"
+" :type frame: float\n"
+" :arg group: The name of the group the F-Curve should be added to if it doesn't exist yet.\n"
+" :type group: str\n"
+" :return: Success of keyframe insertion.\n"
+" :rtype: boolean";
+
static PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args)
{
PyObject *result;
@@ -1718,16 +1809,33 @@ static PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *arg
char *path_full= NULL;
int index= -1;
float cfra= FLT_MAX;
+ char *group_name= NULL;
- if(pyrna_struct_keyframe_parse(&self->ptr, args, "bpy_struct.keyframe_insert():", &path_full, &index, &cfra) == -1)
+ if(pyrna_struct_keyframe_parse(&self->ptr, args, "bpy_struct.keyframe_insert():", &path_full, &index, &cfra, &group_name) == -1)
return NULL;
- result= PyBool_FromLong(insert_keyframe((ID *)self->ptr.id.data, NULL, NULL, path_full, index, cfra, 0));
+ result= PyBool_FromLong(insert_keyframe((ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, 0));
MEM_freeN(path_full);
return result;
}
+static char pyrna_struct_keyframe_delete_doc[] =
+".. method:: keyframe_delete(path, index=-1, frame=bpy.context.scene.frame_current)\n"
+"\n"
+" Remove a keyframe from this properties fcurve.\n"
+"\n"
+" :arg path: path to the property to remove a key, analogous to the fcurve's data path.\n"
+" :type path: string\n"
+" :arg index: array index of the property to remove a key. Defaults to -1 removing all indicies or a single channel if the property is not an array.\n"
+" :type index: int\n"
+" :arg frame: The frame on which the keyframe is deleted, defaulting to the current frame.\n"
+" :type frame: float\n"
+" :arg group: The name of the group the F-Curve should be added to if it doesn't exist yet.\n"
+" :type group: str\n"
+" :return: Success of keyframe deleation.\n"
+" :rtype: boolean";
+
static PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args)
{
PyObject *result;
@@ -1735,49 +1843,40 @@ static PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *arg
char *path_full= NULL;
int index= -1;
float cfra= FLT_MAX;
+ char *group_name= NULL;
- if(pyrna_struct_keyframe_parse(&self->ptr, args, "bpy_struct.keyframe_delete():", &path_full, &index, &cfra) == -1)
+ if(pyrna_struct_keyframe_parse(&self->ptr, args, "bpy_struct.keyframe_delete():", &path_full, &index, &cfra, &group_name) == -1)
return NULL;
- result= PyBool_FromLong(delete_keyframe((ID *)self->ptr.id.data, NULL, NULL, path_full, index, cfra, 0));
+ result= PyBool_FromLong(delete_keyframe((ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, 0));
MEM_freeN(path_full);
return result;
}
+static char pyrna_struct_driver_add_doc[] =
+".. method:: driver_add(path, index=-1)\n"
+"\n"
+" Adds driver(s) to the given property\n"
+"\n"
+" :arg path: path to the property to drive, analogous to the fcurve's data path.\n"
+" :type path: string\n"
+" :arg index: array index of the property drive. Defaults to -1 for all indicies or a single channel if the property is not an array.\n"
+" :type index: int\n"
+" :return: The driver(s) added.\n"
+" :rtype: :class:`FCurve` or list if index is -1 with an array property.";
+
static PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
{
char *path, *path_full;
- int index= -1; /* default to all */
- PropertyRNA *prop;
+ int index= -1;
PyObject *ret;
if (!PyArg_ParseTuple(args, "s|i:driver_add", &path, &index))
return NULL;
- if (self->ptr.data==NULL) {
- PyErr_Format( PyExc_TypeError, "bpy_struct.driver_add(): this struct has no data, cant be animated", path);
- return NULL;
- }
-
- prop = RNA_struct_find_property(&self->ptr, path);
-
- if (prop==NULL) {
- PyErr_Format( PyExc_TypeError, "bpy_struct.driver_add(): property \"%s\" not found", path);
- return NULL;
- }
-
- if (!RNA_property_animateable(&self->ptr, prop)) {
- PyErr_Format( PyExc_TypeError, "bpy_struct.driver_add(): 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, "bpy_struct.driver_add(): could not make path to \"%s\"", path);
+ if(pyrna_struct_anim_args_parse(&self->ptr, "bpy_struct.driver_add():", path, &path_full, &index) < 0)
return NULL;
- }
if(ANIM_add_driver((ID *)self->ptr.id.data, path_full, index, 0, DRIVER_TYPE_PYTHON)) {
ID *id= self->ptr.id.data;
@@ -1804,8 +1903,8 @@ static PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
}
}
else {
- ret= Py_None;
- Py_INCREF(ret);
+ PyErr_SetString(PyExc_TypeError, "bpy_struct.driver_add(): failed because of an internal error");
+ return NULL;
}
MEM_freeN(path_full);
@@ -1813,6 +1912,47 @@ static PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
return ret;
}
+
+static char pyrna_struct_driver_remove_doc[] =
+".. method:: driver_remove(path, index=-1)\n"
+"\n"
+" Remove driver(s) from the given property\n"
+"\n"
+" :arg path: path to the property to drive, analogous to the fcurve's data path.\n"
+" :type path: string\n"
+" :arg index: array index of the property drive. Defaults to -1 for all indicies or a single channel if the property is not an array.\n"
+" :type index: int\n"
+" :return: Success of driver removal.\n"
+" :rtype: boolean";
+
+static PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
+{
+ char *path, *path_full;
+ int index= -1;
+ PyObject *ret;
+
+ if (!PyArg_ParseTuple(args, "s|i:driver_remove", &path, &index))
+ return NULL;
+
+ if(pyrna_struct_anim_args_parse(&self->ptr, "bpy_struct.driver_remove():", path, &path_full, &index) < 0)
+ return NULL;
+
+ ret= PyBool_FromLong(ANIM_remove_driver((ID *)self->ptr.id.data, path_full, index, 0));
+
+ MEM_freeN(path_full);
+
+ return ret;
+}
+
+
+static char pyrna_struct_is_property_set_doc[] =
+".. method:: is_property_set(property)\n"
+"\n"
+" Check if a property is set, use for testing operator properties.\n"
+"\n"
+" :return: True when the property has been set.\n"
+" :rtype: boolean";
+
static PyObject *pyrna_struct_is_property_set(BPy_StructRNA *self, PyObject *args)
{
char *name;
@@ -1823,6 +1963,14 @@ static PyObject *pyrna_struct_is_property_set(BPy_StructRNA *self, PyObject *arg
return PyBool_FromLong(RNA_property_is_set(&self->ptr, name));
}
+static char pyrna_struct_is_property_hidden_doc[] =
+".. method:: is_property_hidden(property)\n"
+"\n"
+" Check if a property is hidden.\n"
+"\n"
+" :return: True when the property is hidden.\n"
+" :rtype: boolean";
+
static PyObject *pyrna_struct_is_property_hidden(BPy_StructRNA *self, PyObject *args)
{
PropertyRNA *prop;
@@ -1838,6 +1986,11 @@ static PyObject *pyrna_struct_is_property_hidden(BPy_StructRNA *self, PyObject *
return PyBool_FromLong(hidden);
}
+static char pyrna_struct_path_resolve_doc[] =
+".. method:: path_resolve(path)\n"
+"\n"
+" Returns the property from the path given or None if the property is not found.";
+
static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *value)
{
char *path= _PyUnicode_AsString(value);
@@ -1845,7 +1998,7 @@ static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *value)
PropertyRNA *r_prop;
if(path==NULL) {
- PyErr_SetString( PyExc_TypeError, "bpy_struct.items(): is only valid for collection types" );
+ PyErr_SetString(PyExc_TypeError, "bpy_struct.path_resolve(): accepts only a single string argument");
return NULL;
}
@@ -1855,20 +2008,30 @@ static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *value)
Py_RETURN_NONE;
}
-static PyObject *pyrna_struct_path_to_id(BPy_StructRNA *self, PyObject *args)
+static char pyrna_struct_path_from_id_doc[] =
+".. method:: path_from_id(property=\"\")\n"
+"\n"
+" Returns the data path from the ID to this object (string).\n"
+"\n"
+" :arg property: Optional property name which can be used if the path is to a property of this object.\n"
+" :type property: string\n"
+" :return: The path from :class:`bpy_struct.id_data` to this struct and property (when given).\n"
+" :rtype: str";
+
+static PyObject *pyrna_struct_path_from_id(BPy_StructRNA *self, PyObject *args)
{
char *name= NULL;
char *path;
PropertyRNA *prop;
PyObject *ret;
- if (!PyArg_ParseTuple(args, "|s:path_to_id", &name))
+ if (!PyArg_ParseTuple(args, "|s:path_from_id", &name))
return NULL;
if(name) {
prop= RNA_struct_find_property(&self->ptr, name);
if(prop==NULL) {
- PyErr_Format(PyExc_TypeError, "%.200s.path_to_id(\"%.200s\") not found", RNA_struct_identifier(self->ptr.type), name);
+ PyErr_Format(PyExc_TypeError, "%.200s.path_from_id(\"%.200s\") not found", RNA_struct_identifier(self->ptr.type), name);
return NULL;
}
@@ -1879,8 +2042,8 @@ static PyObject *pyrna_struct_path_to_id(BPy_StructRNA *self, PyObject *args)
}
if(path==NULL) {
- if(name) PyErr_Format(PyExc_TypeError, "%.200s.path_to_id(\"%s\") found but does not support path creation", RNA_struct_identifier(self->ptr.type), name);
- else PyErr_Format(PyExc_TypeError, "%.200s.path_to_id() does not support path creation for this type", RNA_struct_identifier(self->ptr.type));
+ if(name) PyErr_Format(PyExc_TypeError, "%.200s.path_from_id(\"%s\") found but does not support path creation", RNA_struct_identifier(self->ptr.type), name);
+ else PyErr_Format(PyExc_TypeError, "%.200s.path_from_id() does not support path creation for this type", RNA_struct_identifier(self->ptr.type));
return NULL;
}
@@ -1890,14 +2053,15 @@ static PyObject *pyrna_struct_path_to_id(BPy_StructRNA *self, PyObject *args)
return ret;
}
-static PyObject *pyrna_struct_recast_type(BPy_StructRNA *self, PyObject *args)
-{
- PointerRNA r_ptr;
- RNA_pointer_recast(&self->ptr, &r_ptr);
- return pyrna_struct_CreatePyObject(&r_ptr);
-}
+static char pyrna_prop_path_from_id_doc[] =
+".. method:: path_from_id()\n"
+"\n"
+" Returns the data path from the ID to this property (string).\n"
+"\n"
+" :return: The path from :class:`bpy_struct.id_data` to this property.\n"
+" :rtype: str";
-static PyObject *pyrna_prop_path_to_id(BPy_PropertyRNA *self)
+static PyObject *pyrna_prop_path_from_id(BPy_PropertyRNA *self)
{
char *path;
PropertyRNA *prop = self->prop;
@@ -1906,7 +2070,7 @@ static PyObject *pyrna_prop_path_to_id(BPy_PropertyRNA *self)
path= RNA_path_from_ID_to_property(&self->ptr, self->prop);
if(path==NULL) {
- PyErr_Format(PyExc_TypeError, "%.200s.%.200s.path_to_id() does not support path creation for this type", RNA_struct_identifier(self->ptr.type), RNA_property_identifier(prop));
+ PyErr_Format(PyExc_TypeError, "%.200s.%.200s.path_from_id() does not support path creation for this type", RNA_struct_identifier(self->ptr.type), RNA_property_identifier(prop));
return NULL;
}
@@ -1916,6 +2080,21 @@ static PyObject *pyrna_prop_path_to_id(BPy_PropertyRNA *self)
return ret;
}
+static char pyrna_struct_recast_type_doc[] =
+".. method:: recast_type()\n"
+"\n"
+" Return a new instance, this is needed because types such as textures can be changed at runtime.\n"
+"\n"
+" :return: a new instance of this object with the type initialized again.\n"
+" :rtype: subclass of :class:`bpy_struct`";
+
+static PyObject *pyrna_struct_recast_type(BPy_StructRNA *self, PyObject *args)
+{
+ PointerRNA r_ptr;
+ RNA_pointer_recast(&self->ptr, &r_ptr);
+ return pyrna_struct_CreatePyObject(&r_ptr);
+}
+
static void pyrna_dir_members_py(PyObject *list, PyObject *self)
{
PyObject *dict;
@@ -2284,7 +2463,7 @@ static PyGetSetDef pyrna_prop_getseters[] = {
#endif
static PyGetSetDef pyrna_struct_getseters[] = {
- {"id_data", (getter)pyrna_struct_get_id_data, (setter)NULL, "The ID data this datablock is from, (not available for all data)", NULL},
+ {"id_data", (getter)pyrna_struct_get_id_data, (setter)NULL, "The :class:`ID` object this datablock is from or None, (not available for all data types)", NULL},
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
};
@@ -2361,6 +2540,18 @@ static PyObject *pyrna_prop_values(BPy_PropertyRNA *self)
return ret;
}
+static char pyrna_struct_get_doc[] =
+".. method:: get(key, default=None)\n"
+"\n"
+" Returns the value of the custom property assigned to key or default when not found (matches pythons dictionary function of the same name).\n"
+"\n"
+" :arg key: The key assosiated with the custom property.\n"
+" :type key: string\n"
+" :arg default: Optional argument for the value to return if *key* is not found.\n"
+// " :type default: Undefined\n"
+"\n"
+" .. note:: Only :class:`ID`, :class:`Bone` and :class:`PoseBone` classes support custom properties.\n";
+
static PyObject *pyrna_struct_get(BPy_StructRNA *self, PyObject *args)
{
IDProperty *group, *idprop;
@@ -2389,6 +2580,16 @@ static PyObject *pyrna_struct_get(BPy_StructRNA *self, PyObject *args)
return def;
}
+static char pyrna_struct_as_pointer_doc[] =
+".. method:: as_pointer()\n"
+"\n"
+" Returns capsule which holds a pointer to blenders internal data\n"
+"\n"
+" :return: capsule with a name set from the struct type.\n"
+" :rtype: PyCapsule\n"
+"\n"
+" .. note:: This is intended only for advanced script writers who need to pass blender data to their own C/Python modules.\n";
+
static PyObject *pyrna_struct_as_pointer(BPy_StructRNA *self)
{
if(self->ptr.data)
@@ -2705,23 +2906,23 @@ PyObject *pyrna_prop_collection_iter(BPy_PropertyRNA *self)
static struct PyMethodDef pyrna_struct_methods[] = {
/* only for PointerRNA's with ID'props */
- {"keys", (PyCFunction)pyrna_struct_keys, METH_NOARGS, NULL},
- {"values", (PyCFunction)pyrna_struct_values, METH_NOARGS, NULL},
- {"items", (PyCFunction)pyrna_struct_items, METH_NOARGS, NULL},
-
- {"get", (PyCFunction)pyrna_struct_get, METH_VARARGS, NULL},
-
- {"as_pointer", (PyCFunction)pyrna_struct_as_pointer, METH_NOARGS, NULL},
-
- /* maybe this become and ID function */
- {"keyframe_insert", (PyCFunction)pyrna_struct_keyframe_insert, METH_VARARGS, NULL},
- {"keyframe_delete", (PyCFunction)pyrna_struct_keyframe_delete, METH_VARARGS, NULL},
- {"driver_add", (PyCFunction)pyrna_struct_driver_add, METH_VARARGS, NULL},
- {"is_property_set", (PyCFunction)pyrna_struct_is_property_set, METH_VARARGS, NULL},
- {"is_property_hidden", (PyCFunction)pyrna_struct_is_property_hidden, METH_VARARGS, NULL},
- {"path_resolve", (PyCFunction)pyrna_struct_path_resolve, METH_O, NULL},
- {"path_to_id", (PyCFunction)pyrna_struct_path_to_id, METH_VARARGS, NULL},
- {"recast_type", (PyCFunction)pyrna_struct_recast_type, METH_NOARGS, NULL},
+ {"keys", (PyCFunction)pyrna_struct_keys, METH_NOARGS, pyrna_struct_keys_doc},
+ {"values", (PyCFunction)pyrna_struct_values, METH_NOARGS, pyrna_struct_values_doc},
+ {"items", (PyCFunction)pyrna_struct_items, METH_NOARGS, pyrna_struct_items_doc},
+
+ {"get", (PyCFunction)pyrna_struct_get, METH_VARARGS, pyrna_struct_get_doc},
+
+ {"as_pointer", (PyCFunction)pyrna_struct_as_pointer, METH_NOARGS, pyrna_struct_as_pointer_doc},
+
+ {"keyframe_insert", (PyCFunction)pyrna_struct_keyframe_insert, METH_VARARGS, pyrna_struct_keyframe_insert_doc},
+ {"keyframe_delete", (PyCFunction)pyrna_struct_keyframe_delete, METH_VARARGS, pyrna_struct_keyframe_delete_doc},
+ {"driver_add", (PyCFunction)pyrna_struct_driver_add, METH_VARARGS, pyrna_struct_driver_add_doc},
+ {"driver_remove", (PyCFunction)pyrna_struct_driver_remove, METH_VARARGS, pyrna_struct_driver_remove_doc},
+ {"is_property_set", (PyCFunction)pyrna_struct_is_property_set, METH_VARARGS, pyrna_struct_is_property_set_doc},
+ {"is_property_hidden", (PyCFunction)pyrna_struct_is_property_hidden, METH_VARARGS, pyrna_struct_is_property_hidden_doc},
+ {"path_resolve", (PyCFunction)pyrna_struct_path_resolve, METH_O, pyrna_struct_path_resolve_doc},
+ {"path_from_id", (PyCFunction)pyrna_struct_path_from_id, METH_VARARGS, pyrna_struct_path_from_id_doc},
+ {"recast_type", (PyCFunction)pyrna_struct_recast_type, METH_NOARGS, pyrna_struct_recast_type_doc},
{"__dir__", (PyCFunction)pyrna_struct_dir, METH_NOARGS, NULL},
/* experemental */
@@ -2732,7 +2933,7 @@ static struct PyMethodDef pyrna_struct_methods[] = {
};
static struct PyMethodDef pyrna_prop_methods[] = {
- {"path_to_id", (PyCFunction)pyrna_prop_path_to_id, METH_NOARGS, NULL},
+ {"path_from_id", (PyCFunction)pyrna_prop_path_from_id, METH_NOARGS, pyrna_prop_path_from_id_doc},
{"__dir__", (PyCFunction)pyrna_prop_dir, METH_NOARGS, NULL},
{NULL, NULL, 0, NULL}
};