<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=NL link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:12.0pt'>Hi,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:12.0pt'>Currently I am working on enhancing my space tree addon and I want to link or append particle settings from a bundled library.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:12.0pt'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:12.0pt'>Now bpy.data.libraries.load() works fine but the objects returned in by the context manager do NOT expose a particles attribute so I am forced to link the object with the associated particle system and get the particlesettings as side effect. This is not so desirable because I have no need for the object itself. (see code below)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:12.0pt'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:12.0pt'>Am I missing something here/could this be done more elegantly or is not having a .particles attribute an omission in the API perhaps?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:12.0pt'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:12.0pt'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:12.0pt'>Thnx,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:12.0pt'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:12.0pt'>-- Michel (varkenvarken).</span><span lang=EN-US><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>def load_particlesettings(library, object_name, settings):<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>    beforep = set(m.name for m in bpy.data.particles)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>    before  = set(m.name for m in bpy.data.objects)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>    with bpy.data.libraries.load(library) as (data_from, data_to):<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>        data_to.objects = [m for m in data_from.objects if m == object_name]<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>    afterp = set(m.name for m in bpy.data.particles)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>    after = set(m.name for m in bpy.data.objects)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>    new = after - before<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>    if len(new) != 1:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>        raise ValueError("While loading object %s from library %s %d objects were found (%s) instead of just 1"%(<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>            object_name,library,len(new),str(new)))<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>    new = afterp - beforep<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>    if len(new) != 1:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>        raise ValueError("While loading particle setting %s from object %s in library %s %d objects were found (%s) instead of just 1"%(settings,object_name,library,len(new),str(new)))<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>    return bpy.data.particles[new.pop()]<o:p></o:p></span></p></div></body></html>