From abab9fc3de507930dceb2b08c4e83d2adb6338bc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 18 Mar 2006 17:24:59 +0000 Subject: [PATCH] Added object.dupliGroup so objects can access the groups they instance. This is very confusing. Since in object has ob.setDupliGroup() # Enable/Disable Dupligroup ob.getDupliGroup() # see if its enabled. ob.dupliGroup # the group data this object is instancing. Not yet added ob.groups # Groups that use this object. --- source/blender/python/api2_2x/Object.c | 23 +++++++++++++++++++-- source/blender/python/api2_2x/doc/Object.py | 5 +++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c index c8083ff1890..f6d1a1ad980 100644 --- a/source/blender/python/api2_2x/Object.c +++ b/source/blender/python/api2_2x/Object.c @@ -106,6 +106,7 @@ struct rctf; #include "logic.h" #include "Effect.h" #include "Pose.h" +#include "Group.h" #include "gen_utils.h" #include "BIF_editkey.h" @@ -3522,7 +3523,9 @@ static PyObject *Object_getAttr( BPy_Object * obj, char *name ) return PyInt_FromLong( obj->object->id.us ); if( StringEqual( name, "protectFlags" ) ) return PyInt_FromLong( obj->object->protectflag ); - + if( StringEqual( name, "dupliGroup" ) ) + return Group_CreatePyObject( obj->object->dup_group ); + /* not an attribute, search the methods table */ return Py_FindMethod( BPy_Object_methods, ( PyObject * ) obj, name ); } @@ -3741,7 +3744,23 @@ static int Object_setAttr( BPy_Object * obj, char *name, PyObject * value ) object->protectflag = (short)flag; return 0; } - + if( StringEqual( name, "dupliGroup" ) ) { + PyObject *pyob=NULL; + BPy_Group *pygrp=NULL; + Group *group; + if( !PyArg_Parse( value, "O", &pyob) ) + return ( EXPP_ReturnPyObjError( PyExc_TypeError, + "expected a group" ) ); + if (pyob==Py_None) { + object->dup_group= NULL; + } else { + pygrp= (BPy_Group *)pyob; + object->dup_group= pygrp->group; + } + + + return 0; + } /* SECOND, handle all the attributes that passes the value as a tuple to another function */ diff --git a/source/blender/python/api2_2x/doc/Object.py b/source/blender/python/api2_2x/doc/Object.py index 2815ac89e20..5669728e2f7 100644 --- a/source/blender/python/api2_2x/doc/Object.py +++ b/source/blender/python/api2_2x/doc/Object.py @@ -261,6 +261,11 @@ class Object: - bit 7: Y size - bit 8: Z size @type protectFlags: int + @ivar dupliGroup: The dupli group that this object is an instance of. + This does not enable or disable the dupligroup option, for that use + getDupliGroup and setDupliGroup. + The dupliGroup is None when this object does not have a dupliGroup. + @type dupliGroup: list of integers """ def buildParts():