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:
authorWillian Padovani Germano <wpgermano@gmail.com>2005-02-02 06:38:31 +0300
committerWillian Padovani Germano <wpgermano@gmail.com>2005-02-02 06:38:31 +0300
commit41b251fab087f6f6dbea4439136949c392c2019d (patch)
treeac538bf5626308e33ca00707c8e60c46561b351a /source/blender/python/api2_2x
parent78f133b8a7bc1db280d5d052bf83d7ea959cd1cb (diff)
BPython:
- Fix related to bug #2157: crash in Blender.Image.image.reload() method. "G.sima" was not being checked for validity. Fix by Joilnen B. Leite (pidhash). Thanks! http://projects.blender.org/tracker/?func=detail&atid=125&aid=2157&group_id=9 - Added optional argument to Blender.Object.object.getData() method: getData(only_name = True) or (only_name = 1) or (1) will return only the obdata name, not a wrapper for the given struct. This is a test based on a request by Campbell Barton who submitted code for his proposed .getDataName() method (thanks!). - doc updates and small fixes.
Diffstat (limited to 'source/blender/python/api2_2x')
-rw-r--r--source/blender/python/api2_2x/Image.c4
-rw-r--r--source/blender/python/api2_2x/Object.c41
-rw-r--r--source/blender/python/api2_2x/doc/NMesh.py8
-rw-r--r--source/blender/python/api2_2x/doc/Object.py17
4 files changed, 48 insertions, 22 deletions
diff --git a/source/blender/python/api2_2x/Image.c b/source/blender/python/api2_2x/Image.c
index a27cba7d2a2..d4debde9000 100644
--- a/source/blender/python/api2_2x/Image.c
+++ b/source/blender/python/api2_2x/Image.c
@@ -25,7 +25,7 @@
*
* This is a new part of Blender.
*
- * Contributor(s): Willian P. Germano, Campbell Barton
+ * Contributor(s): Willian P. Germano, Campbell Barton, Joilnen B. Leite
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
@@ -481,7 +481,7 @@ static PyObject *Image_reload( BPy_Image * self )
free_image_buffers( img ); /* force read again */
img->ok = 1;
- image_changed( G.sima, 0 );
+ if (G.sima) image_changed( G.sima, 0 );
Py_INCREF( Py_None );
return Py_None;
diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c
index afc093a6965..f7c0c6c33e7 100644
--- a/source/blender/python/api2_2x/Object.c
+++ b/source/blender/python/api2_2x/Object.c
@@ -100,7 +100,7 @@ static PyObject *Object_buildParts( BPy_Object * self );
static PyObject *Object_clearIpo( BPy_Object * self );
static PyObject *Object_clrParent( BPy_Object * self, PyObject * args );
static PyObject *Object_clearTrack( BPy_Object * self, PyObject * args );
-static PyObject *Object_getData( BPy_Object * self );
+static PyObject *Object_getData(BPy_Object *self, PyObject *a, PyObject *kwd);
static PyObject *Object_getDeltaLocation( BPy_Object * self );
static PyObject *Object_getDrawMode( BPy_Object * self );
static PyObject *Object_getDrawType( BPy_Object * self );
@@ -165,8 +165,10 @@ hierarchy (faster)"},
"Make this object not track another anymore. Optionally specify:\n\
mode\n\t2: Keep object transform\nfast\n\t>0: Don't update scene \
hierarchy (faster)"},
- {"getData", ( PyCFunction ) Object_getData, METH_NOARGS,
- "Returns the datablock object containing the object's data, e.g. Mesh"},
+ {"getData", ( PyCFunction ) Object_getData, METH_VARARGS | METH_KEYWORDS,
+ "(only_name = 0) - Returns the datablock object containing the object's \
+data, e.g. Mesh.\n\
+If 'only_name' is nonzero or True, only the name of the datablock is returned"},
{"getDeltaLocation", ( PyCFunction ) Object_getDeltaLocation,
METH_NOARGS,
"Returns the object's delta location (x, y, z)"},
@@ -728,10 +730,16 @@ int EXPP_add_obdata( struct Object *object )
}
-static PyObject *Object_getData( BPy_Object * self )
+static PyObject *Object_getData( BPy_Object *self, PyObject *a, PyObject *kwd )
{
PyObject *data_object;
Object *object = self->object;
+ int only_name = 0;
+ static char *kwlist[] = {"only_name", NULL};
+
+ if (!PyArg_ParseTupleAndKeywords(a, kwd, "|i", kwlist, &only_name))
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected nothing or an int (keyword 'only_name') as argument" );
/* if there's no obdata, try to create it */
if( object->data == NULL ) {
@@ -741,6 +749,17 @@ static PyObject *Object_getData( BPy_Object * self )
}
}
+ /* user wants only the name of the data object */
+ if (only_name) {
+ ID *id = &object->id;
+ data_object = Py_BuildValue("s", id->name+2);
+
+ if (data_object) return data_object;
+ return EXPP_ReturnPyObjError (PyExc_MemoryError,
+ "could not create a string pyobject!");
+ }
+
+ /* user wants the data object wrapper */
data_object = NULL;
switch ( object->type ) {
@@ -2163,8 +2182,18 @@ static PyObject *Object_getAttr( BPy_Object * obj, char *name )
if( StringEqual( name, "track" ) )
return ( Object_CreatePyObject( object->track ) );
- if( StringEqual( name, "data" ) )
- return ( Object_getData( obj ) );
+ if( StringEqual( name, "data" ) ) {
+ PyObject *getdata, *tuple = PyTuple_New(0);
+
+ if (!tuple)
+ return EXPP_ReturnPyObjError (PyExc_MemoryError,
+ "couldn't create an empty tuple!");
+
+ getdata = Object_getData( obj, tuple, NULL );
+
+ Py_DECREF(tuple);
+ return getdata;
+ }
if( StringEqual( name, "ipo" ) ) {
if( object->ipo == NULL ) {
/* There's no ipo linked to the object, return Py_None. */
diff --git a/source/blender/python/api2_2x/doc/NMesh.py b/source/blender/python/api2_2x/doc/NMesh.py
index ed016880c24..4b81dcd5831 100644
--- a/source/blender/python/api2_2x/doc/NMesh.py
+++ b/source/blender/python/api2_2x/doc/NMesh.py
@@ -321,13 +321,9 @@ class NMesh:
def removeEdge():
"""
- remove an edge between two vertices.
+ Remove an edge between two vertices.
All faces using this edge are removed from faces list.
You can only call this method if mesh has edge data.
- @type v1: NMVert
- @param v1: the first vertex of the edge.
- @type v2: NMVert
- @param v2: the second vertex of the edge.
"""
def addFace(face):
@@ -342,8 +338,6 @@ class NMesh:
def removeFace():
"""
Remove a face for face list and remove edges no more used by any other face (if edge data exists).
- @type face: NMFace
- @param face: the face to add to the mesh.
"""
def addEdgesData():
diff --git a/source/blender/python/api2_2x/doc/Object.py b/source/blender/python/api2_2x/doc/Object.py
index c2d1db093ca..ddf8269fbae 100644
--- a/source/blender/python/api2_2x/doc/Object.py
+++ b/source/blender/python/api2_2x/doc/Object.py
@@ -3,8 +3,8 @@
"""
The Blender.Object submodule
-B{New}: 'old_worldspace' parameter in L{Object.Object.getMatrix}, which now
-defaults to 'worldspace'.
+B{New}: L{Object.getData} now accepts an optional bool keyword argument to
+define if the user wants the data object or just its name.
Object
======
@@ -186,13 +186,16 @@ class Object:
other value, or no value at all will update the scene hierarchy.
"""
- def getData():
+ def getData(only_name = False):
"""
- Returns the Datablock object containing the object's data. For example the
- Mesh, Lamp or the Camera.
- @rtype: Object type specific
+ Returns the Datablock object (new: or just its name) containing the
+ object's data. For example the Mesh, Lamp or the Camera.
+ @type only_name: bool
+ @param only_name: if True on nonzero, only the name of the data object
+ is returned.
+ @rtype: Object type specific or string
@return: Depending on the type of the Object, it returns a specific object
- for the data requested.
+ for the data requested. If only_name is True, it returns a string.
"""
def getDeltaLocation():