[ #2423 ] Object.getParentSubName
- this is a submitted patch by lordbosh - adds to ability to get the bone name when and object is parented to a bone
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
*
|
||||
* Contributor(s): Michel Selten, Willian Germano, Jacques Guignot,
|
||||
* Joseph Gilbert, Stephen Swaney, Bala Gi, Campbell Barton, Johnny Matthews,
|
||||
* Ken Hughes
|
||||
* Ken Hughes, Alex Mole
|
||||
*
|
||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
@@ -175,6 +175,7 @@ static PyObject *Object_getMaterials( BPy_Object * self, PyObject * args );
|
||||
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_getParentBoneName( 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 );
|
||||
@@ -324,6 +325,8 @@ automatic when the script finishes."},
|
||||
"Returns the name of the object"},
|
||||
{"getParent", ( PyCFunction ) Object_getParent, METH_NOARGS,
|
||||
"Returns the object's parent object"},
|
||||
{"getParentBoneName", ( PyCFunction ) Object_getParentBoneName, 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,
|
||||
@@ -1264,6 +1267,23 @@ static PyObject *Object_getParent( BPy_Object * self )
|
||||
"couldn't get Object.parent attribute" ) );
|
||||
}
|
||||
|
||||
static PyObject *Object_getParentBoneName( 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 bone name" ) );
|
||||
}
|
||||
|
||||
static PyObject *Object_getSize( BPy_Object * self, PyObject * args )
|
||||
{
|
||||
PyObject *attr = Py_BuildValue( "fff",
|
||||
@@ -2706,6 +2726,14 @@ static PyObject *Object_getAttr( BPy_Object * obj, char *name )
|
||||
return ( Py_None );
|
||||
}
|
||||
}
|
||||
if( StringEqual( name, "parentbonename" ) ) {
|
||||
if( object->parent && object->parsubstr[0] )
|
||||
return ( Py_BuildValue("s", object->parsubstr) );
|
||||
else {
|
||||
Py_INCREF( Py_None );
|
||||
return ( Py_None );
|
||||
}
|
||||
}
|
||||
|
||||
if( StringEqual( name, "track" ) )
|
||||
return ( Object_CreatePyObject( object->track ) );
|
||||
|
||||
@@ -355,6 +355,15 @@ class Object:
|
||||
@return: (SizeX, SizeY, SizeZ)
|
||||
"""
|
||||
|
||||
def getParentBoneName():
|
||||
"""
|
||||
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 getTimeOffset():
|
||||
"""
|
||||
Returns the time offset of the object's animation.
|
||||
|
||||
Reference in New Issue
Block a user