[Bf-python] dupli_group attribute of ID Object

James Crowther jamesharrycrowther at gmail.com
Tue Jun 28 09:01:19 CEST 2016


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20160628/4ea6a501/attachment.html>


More information about the Bf-python mailing list