[Bf-python] dupli_group attribute of ID Object

Diego Borghetti bdiego at gmail.com
Tue Jun 28 09:46:49 CEST 2016


Check the value of dupli_type.You can have dupli_type set to GROUP but
with no group assign (which it's fine). It will be easy if you add and
empty and check in the Object properties how it works (under
Duplication). Or at least that is what I do from my scripts :P

I never check, but I assume that if dupli_type is set to anything
else, the default value of dupli_group will be None (because there is
no use of the attribute).
Campbell, is this right ?

On Tue, Jun 28, 2016 at 8:01 AM, James Crowther
<jamesharrycrowther at gmail.com> wrote:
> Hi there,
>              I'm in need of some help with understanding the 'dupli_group'
> attribute. I have a script that looks at this attribute to find what groups
> are there. But, most of the time my script returns that this attribute is
> None. Occasionally it will return the group which I assume is the normal
> behaviour of this attribute. It seems to be random whether my script finds
> the attribute to contain the correct value.
>
> I'm trying to debug why this might occur. I have a theory that it may be
> because my script attempts to determine which attributes are readonly; by
> attempting to write to all the attributes of the object in question. For
> example, take the cube on the default scene. I do this by using the
> following:
>
> for attr in dir(D.objects['Cube']):
>
>   # get the data of the attribute
> attr_data = getattr(D.objects['Cube'], attr)
>
> if type(attr_data) in {str, int, Vector, Color, Euler, float, bool}:
>
>     try:
>
>         setattr(D.objects['Cube'], attr, attr_data)
>
>
>
>     except:
>         read_only.append(attr)
>
> elif type(attr_data) is None:
>     #add the attribute to a list of attributes that are not yet initialised
> with any data.
>     cls_uninitialised.append(attr)
>
>
> This is all done during one update frame in blender, the above code is
> called from a handler in bpy.app.handlers.scene_update_post
>
> As far as I can tell this is the only attribute that does this. Most of the
> time the 'dupli_group' attribute ends up in in the cls_initialised list
> since the result of type(attr_data) is None. But when I check manually for
> example:
>
>>>>D.objects['some_object'].dupli_group
> bpy.data.groups['some_group']
>
> So, I guess I'm really interested to know if dupli_group is always
> guaranteed to have a value if the object is actually using it and if setting
> other attributes of the same object might cause it to momentarily be set to
> None.
>
> Since this behaviour appears to be random at the moment, I am guessing it
> could be due to the fact that python dictionaries store key, value pairs in
> a different order each time and occasionally this order results in the
> dupli_group attribute being something other than None in my code.
> That is a long shot though, since it seems rather odd that this would be the
> case.
>
> I'd appreciate answers to my direct question on the effect of setting
> attributes and also any other ideas for things to try!
>
> Thanks!
>
> James
>
>
>
> _______________________________________________
> Bf-python mailing list
> Bf-python at blender.org
> https://lists.blender.org/mailman/listinfo/bf-python
>



-- 
--

                       Diego



More information about the Bf-python mailing list