Thanks,<div><br></div><div>would it be possible that the bpy.ops.wm.collada_import method could select all imported objects ?</div><div>for instance if I have a car plus 4 wheels in the file "atrv257.dae", and I do:</div>


<div>#</div><div><div>bpy.ops.wm.collada_import(filepath="/home/pierrick/atrv257.dae")</div><div>print(bpy.context.selected_objects)</div></div>
<div>#</div><div>the output is only:</div><div>[bpy.data.objects["Wheel_1"]]</div><div><br></div><div>and I would expect to have something like:</div><div><div>bpy.ops.wm.link_append(directory="/home/pierrick/atrv.blend/Object/", link=False, files=[{'name': 'ATRV'}, {'name': 'Wheel.4'}, {'name': 'Wheel.3'}, {'name': 'Wheel.2'}, {'name': 'Wheel.1'}])</div>

<div>print(bpy.context.selected_objects)</div><div>[bpy.data.objects["ATRV.001"], bpy.data.objects["Wheel.4"], bpy.data.objects["Wheel.3"], bpy.data.objects["Wheel.2"], bpy.data.objects["Wheel.1"]]</div>

</div><div><br></div><div><br></div><div>It would be usefull to have something like "autoselect=True" that we can find in bpy.ops.wm.link_append.</div>
<div><br></div><div>Cheers,</div><div><br><div class="gmail_quote">On Tue, May 24, 2011 at 10:25 PM, Campbell Barton <span dir="ltr"><<a href="mailto:ideasman42@gmail.com" target="_blank">ideasman42@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">eek, mixing blender versions like this sounds, painful!<br>
<br>
Committed feature so the datablocks are accessible within the list now.<br>
r36869.<br>
<br>
--- from the docs.<br>
# the loaded objects can be accessed from 'data_to' outside of the context<br>
# since loading the data replaces the strings for the datablocks or None<br>
# if the datablock could not be loaded.<br>
with bpy.data.libraries.load(filepath) as (data_from, data_to):<br>
    data_to.meshes = data_from.meshes<br>
# now operate directly on the loaded data<br>
for mesh in data_to.meshes:<br>
    if mesh is not None:<br>
        print(<a href="http://mesh.name" target="_blank">mesh.name</a>)<br>
<div><div></div><div><br>
<br>
On Tue, May 24, 2011 at 2:51 PM, Pierrick Koch <<a href="mailto:pierrick.koch@gmail.com" target="_blank">pierrick.koch@gmail.com</a>> wrote:<br>
> Thanks,<br>
> Actually, I'm already using bpy.data.libraries.load(filepath) to generate a<br>
> dictionary of my object (thanks to Blender 2.57) [1],<br>
> and then, I use the dictionary in Blender 2.56 (since some code I'm using is<br>
> Python3.1 no 3.2, but this is going to be fixed)<br>
> The probleme with bpy.data.libraries.load(filepath) when used like:<br>
> ####<br>
> filepath = '/usr/local/share/data/morse/components/robots/atrv.blend'<br>
> with bpy.data.libraries.load(filepath) as (src, dest):<br>
>   for obj in src.objects:<br>
>     tmp = obj<br>
>     suffix = 1 # we need to do that in case there is already an object with<br>
> the same name<br>
>     while tmp in bpy.data.objects.keys():<br>
>       tmp='%s%03d' % (obj, suffix)<br>
>       suffix = suffix + 1<br>
>     dest.objects[tmp] = src.objects[obj]<br>
> for obj in dest.objects:<br>
>   bpy.context.scene.objects.link(bpy.data.objects[obj])<br>
> ####<br>
> ...is that we loose the parent relationship, so I had to do something like:<br>
> `bpy.ops.object.constraints_clear()`<br>
> which I'm not sure is the right method to get back that relation, but it<br>
> works.<br>
> [1] <a href="https://github.com/pierriko/morse/blob/master/src/morse/builder/generator.py#L41" target="_blank">https://github.com/pierriko/morse/blob/master/src/morse/builder/generator.py#L41</a><br>
><br>
><br>
> Cheers!<br>
><br>
> On Tue, May 24, 2011 at 9:05 PM, Campbell Barton <<a href="mailto:ideasman42@gmail.com" target="_blank">ideasman42@gmail.com</a>><br>
> wrote:<br>
>><br>
>> Take a look at:<br>
>> bpy.data.libraries.load(...)<br>
>><br>
>> Examples in docs:<br>
>><br>
>> <a href="http://www.blender.org/documentation/blender_python_api_2_57_release/bpy.types.BlendDataLibraries.html#bpy.types.BlendDataLibraries.load" target="_blank">http://www.blender.org/documentation/blender_python_api_2_57_release/bpy.types.BlendDataLibraries.html#bpy.types.BlendDataLibraries.load</a><br>



>><br>
>> This is intended to be used from python rather then the operator since<br>
>> it gives a way to inspect whats in the blend and select the data<br>
>> blocks to add.<br>
>><br>
>> Now you come to mention it, it doesn't give you a list of loaded<br>
>> datablocks which would be useful.<br>
>><br>
>> On Tue, May 24, 2011 at 11:27 AM, Martin Poirier <<a href="mailto:theeth@yahoo.com" target="_blank">theeth@yahoo.com</a>> wrote:<br>
>> ><br>
>> > The link and append operators set the selection to the objects that were<br>
>> > added. (the active object isn't changed though, careful with that.)<br>
>> ><br>
>> > A complete solution (a low level api call) should return all the added<br>
>> > datablocks (dependencies and all, not just top level objects) so you can<br>
>> > detect all new items.<br>
>> ><br>
>> > Martin<br>
>> ><br>
>> > --- On Tue, 5/24/11, Pierrick Koch <<a href="mailto:pierrick.koch@gmail.com" target="_blank">pierrick.koch@gmail.com</a>> wrote:<br>
>> ><br>
>> > From: Pierrick Koch <<a href="mailto:pierrick.koch@gmail.com" target="_blank">pierrick.koch@gmail.com</a>><br>
>> > Subject: [Bf-python] Ask for: link/append/import returns object(s)<br>
>> > instance(s)<br>
>> > To: <a href="mailto:robotics@blender.org" target="_blank">robotics@blender.org</a>, <a href="mailto:bf-python@blender.org" target="_blank">bf-python@blender.org</a><br>
>> > Received: Tuesday, May 24, 2011, 12:52 AM<br>
>> ><br>
>> > Hi everyone,<br>
>> > I am looking for a Python method to link/append/import objects in<br>
>> > Blender that would give me back some info about what has been appended (in<br>
>> > the best case a list of the imported objects instances)...<br>
>> > For instance: let say that in a .blend file I have a car made of the<br>
>> > main structure which contain 4 wheels.<br>
>> > Code:<br>
>> > bpy.ops.wm.link_append(directory="/home/pierrick/atrv.blend/Object",<br>
>> > link=False,<br>
>> >   files=[{'name': 'ATRV'}, {'name': 'Wheel.4'}, {'name': 'Wheel.3'},<br>
>> > {'name': 'Wheel.2'}, {'name': 'Wheel.1'}])<br>
>> > if there was already an object called ATRV, my car will be renamed<br>
>> > ATRV.001,<br>
>> > it would be nice to get an instance of the objects, to avoid pasing by<br>
>> > bpy.data.object<br>
>> > Same with collada: it would be amazing if:<br>
>> > Code:<br>
>> > bpy.ops.wm.collada_import(filepath="/home/pierrick/atrv.dae")<br>
>> > could return something like:<br>
>> > Code:<br>
>> > you_just_imported = {<br>
>> >   'ATRV': [<br>
>> >     'Wheel1',<br>
>> >     'Wheel2',<br>
>> >     'Wheel3',<br>
>> >     'Wheel4'<br>
>> >   ]<br>
>> > }<br>
>> ><br>
>> > Where the string are the real-name of the object in the Blender<br>
>> > instance.<br>
>> > With .001 if there was already another object with the same name in the<br>
>> > scene.<br>
>> > ...<br>
>> > In fact, I'm working on Robotics<br>
>> > <a href="http://wiki.blender.org/index.php/Robotics:Contents" target="_blank">http://wiki.blender.org/index.php/Robotics:Contents</a><br>
>> ><br>
>> > <a href="https://github.com/pierriko/morse/blob/master/src/morse/builder/morsebuilder.py#L61" target="_blank">https://github.com/pierriko/morse/blob/master/src/morse/builder/morsebuilder.py#L61</a><br>
>> ><br>
>> > <a href="https://github.com/pierriko/morse/blob/master/examples/morse/scenarii/ros_example.py" target="_blank">https://github.com/pierriko/morse/blob/master/examples/morse/scenarii/ros_example.py</a><br>
>> > <a href="http://www.openrobots.org/wiki/morse" target="_blank">http://www.openrobots.org/wiki/morse</a><br>
>> > ...<br>
>> > Any idea? shall I open an issue for that?<br>
>> > Cheers,<br>
>> > Pierrick<br>
>> > = This message is cross-posted<br>
>> > on <a href="http://www.blender.org/forum/viewtopic.php?t=20112" target="_blank">http://www.blender.org/forum/viewtopic.php?t=20112</a> =<br>
>> > -----Inline Attachment Follows-----<br>
>> ><br>
>> > _______________________________________________<br>
>> > Bf-python mailing list<br>
>> > <a href="mailto:Bf-python@blender.org" target="_blank">Bf-python@blender.org</a><br>
>> > <a href="http://lists.blender.org/mailman/listinfo/bf-python" target="_blank">http://lists.blender.org/mailman/listinfo/bf-python</a><br>
>> ><br>
>> > _______________________________________________<br>
>> > Bf-python mailing list<br>
>> > <a href="mailto:Bf-python@blender.org" target="_blank">Bf-python@blender.org</a><br>
>> > <a href="http://lists.blender.org/mailman/listinfo/bf-python" target="_blank">http://lists.blender.org/mailman/listinfo/bf-python</a><br>
>> ><br>
>><br>
>><br>
>><br>
>> --<br>
>> - Campbell<br>
>> _______________________________________________<br>
>> Bf-python mailing list<br>
>> <a href="mailto:Bf-python@blender.org" target="_blank">Bf-python@blender.org</a><br>
>> <a href="http://lists.blender.org/mailman/listinfo/bf-python" target="_blank">http://lists.blender.org/mailman/listinfo/bf-python</a><br>
><br>
><br>
><br>
> --<br>
> Pierrick Koch<br>
> Ingénieur GREYC/CNRS, Hanoi<br>
> +841675357334 [UTC+7]<br>
> <a href="http://linkedin.com/in/pierriko" target="_blank">linkedin.com/in/pierriko</a><br>
><br>
> _______________________________________________<br>
> Bf-python mailing list<br>
> <a href="mailto:Bf-python@blender.org" target="_blank">Bf-python@blender.org</a><br>
> <a href="http://lists.blender.org/mailman/listinfo/bf-python" target="_blank">http://lists.blender.org/mailman/listinfo/bf-python</a><br>
><br>
><br>
<br>
<br>
<br>
--<br>
- Campbell<br>
_______________________________________________<br>
Bf-python mailing list<br>
<a href="mailto:Bf-python@blender.org" target="_blank">Bf-python@blender.org</a><br>
<a href="http://lists.blender.org/mailman/listinfo/bf-python" target="_blank">http://lists.blender.org/mailman/listinfo/bf-python</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div><div><div><div><div><div><font face="arial, helvetica, sans-serif"><span style="font-size:x-small"><font color="#666666">Pierrick Koch </font></span></font></div>


<div><font face="arial, helvetica, sans-serif"><span style="font-size:x-small"><font color="#666666">Ingénieur </font></span></font><span style="font-family:arial, helvetica, sans-serif;font-size:x-small"><a href="https://www.greyc.fr" target="_blank"><font color="#999999">GREYC</font></a><font color="#666666">/</font><a href="http://www.cnrs.fr" target="_blank"><font color="#999999">CNRS</font></a><font color="#666666">, Hanoi </font></span></div>


<div><font face="arial, helvetica, sans-serif"><span style="font-size:x-small"><font color="#666666">+841675357334 [UTC+7] </font></span></font></div><div><font face="arial, helvetica, sans-serif"><a href="http://linkedin.com/in/pierriko" target="_blank"><font color="#666666"><b>linkedin<span style="font-size:x-small">.com/in/pierriko</span></b></font></a><font color="#666666" style="font-size:x-small"> </font></font></div>


</div></div></div></div></div><br>
</div>