Page MenuHome

Object_ParentSubName.patch

Authored By
alex mole (lordbosh)
Nov 13 2013, 12:59 PM
Size
3 KB
Subscribers
None

Object_ParentSubName.patch

Index: Object.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Object.c,v
retrieving revision 1.106
diff -u -u -r1.106 Object.c
--- Object.c 2 Apr 2005 17:01:56 -0000 1.106
+++ Object.c 7 Apr 2005 20:34:26 -0000
@@ -29,7 +29,8 @@
*
*
* Contributor(s): Michel Selten, Willian Germano, Jacques Guignot,
- * Joseph Gilbert, Stephen Swaney, Bala Gi, Campbell Barton, Johnny Matthews
+ * Joseph Gilbert, Stephen Swaney, Bala Gi, Campbell Barton, Johnny Matthews,
+ * Alex Mole
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
@@ -131,6 +132,7 @@
static PyObject *Object_getMatrix( BPy_Object * self, PyObject * args );
static PyObject *Object_getName( BPy_Object * self );
static PyObject *Object_getParent( BPy_Object * self );
+static PyObject *Object_getParentSubName( BPy_Object * self );
static PyObject *Object_getSize( BPy_Object * self, PyObject * args );
static PyObject *Object_getTimeOffset( BPy_Object * self );
static PyObject *Object_getTracked( BPy_Object * self );
@@ -226,6 +228,8 @@
"Returns the name of the object"},
{"getParent", ( PyCFunction ) Object_getParent, METH_NOARGS,
"Returns the object's parent object"},
+ {"getParentSubName", ( PyCFunction ) Object_getParentSubName, METH_NOARGS,
+ "Returns None, or the 'sub-name' of the parent (eg. Bone name)"},
{"getSize", ( PyCFunction ) Object_getSize, METH_VARARGS,
"Returns the object's size (x, y, z)"},
{"getTimeOffset", ( PyCFunction ) Object_getTimeOffset, METH_NOARGS,
@@ -1038,6 +1042,23 @@
"couldn't get Object.parent attribute" ) );
}
+static PyObject *Object_getParentSubName( BPy_Object * self )
+{
+ PyObject *attr;
+
+ if( self->object->parent == NULL )
+ return EXPP_incr_ret( Py_None );
+ if( self->object->parsubstr[0] == '\0' )
+ return EXPP_incr_ret( Py_None );
+
+ attr = Py_BuildValue( "s", self->object->parsubstr );
+ if( attr )
+ return attr;
+
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Failed to get parent sub name" ) );
+}
+
static PyObject *Object_getSize( BPy_Object * self, PyObject * args )
{
PyObject *attr = Py_BuildValue( "fff",
@@ -2277,6 +2298,14 @@
if( StringEqual( name, "parent" ) ) {
if( object->parent )
return ( Object_CreatePyObject( object->parent ) );
+ else {
+ Py_INCREF( Py_None );
+ return ( Py_None );
+ }
+ }
+ if( StringEqual( name, "parentsubname" ) ) {
+ if( object->parent && object->parsubstr[0] )
+ return ( Py_BuildValue("s", object->parsubstr) );
else {
Py_INCREF( Py_None );
return ( Py_None );
Index: doc/Object.py
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/doc/Object.py,v
retrieving revision 1.29
diff -u -u -r1.29 Object.py
--- doc/Object.py 2 Apr 2005 17:01:56 -0000 1.29
+++ doc/Object.py 7 Apr 2005 20:34:27 -0000
@@ -329,6 +329,15 @@
returned.
"""
+ def getParentSubName():
+ """
+ Returns the object's parent object's sub name, or None.
+ For objects parented to bones, this is the name of the bone.
+ @rtype: String
+ @return: The parent object sub-name of the object.
+ If not available, None will be returned.
+ """
+
def getSize():
"""
Returns the object's size.

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
a1/d4/6ad60108083016971a57aa0af22d

Event Timeline