Thanks Gilberto,<div><br></div><div>it wors fine for link_append:</div><div>####</div><div><div>bpy.ops.object.select_all(action='DESELECT')</div><div>bpy.ops.wm.link_append(directory="/usr/local/share/data/morse/components/robots/atrv.blend/Object/", link=False, files=[{'name': 'ATRV'}, {'name': 'Wheel.4'}, {'name': 'Wheel.3'}, {'name': 'Wheel.2'}, {'name': 'Wheel.1'}])</div>
<div>for obj in bpy.context.selected_objects:</div><div> print(obj)</div></div><div>####<br><br></div><div>but unfortunately not for Collada (the import method select the last wheel)...</div><div><br></div><div>Cheers,</div>
<div><br><div class="gmail_quote">On Tue, May 24, 2011 at 4:05 PM, Gilberto Echeverria <span dir="ltr"><<a href="mailto:gilberto.echeverria@laas.fr">gilberto.echeverria@laas.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div text="#000000" bgcolor="#ffffff">
Hi Pierrick,<br>
<br>
Looking at the current documentation for Blender, there doesn't seem to
be a return value for operators. I don't know if this could be
implemented.<br>
<br>
For the moment, a possible workaround to find out what objects you have
just linked would be something like this:<br>
<br>
<tt># Deselect all objects in the scene<br>
bpy.ops.object.select_all(DESELECT)<br>
# Import from another file, asking to auto select the new objects:<br>
</tt><div class="im">
<div><tt>bpy.ops.wm.link_append(directory="/home/pierrick/atrv.blend/Object",
link=False, </tt></div>
</div><div><tt> files=[{'name': 'ATRV'}, {'name': 'Wheel.4'}, {'name':
'Wheel.3'}, {'name': 'Wheel.2'}, {'name': 'Wheel.1'}], autoselect=True)<br>
# Read the list of selected objects<br>
for obj in bpy.context.selected_objects:</tt><br>
<br>
<br>
</div>
<div>Hope this helps. Cheers!<br>
Gilberto<br>
</div><div><div></div><div class="h5">
<br>
<br>
On 05/24/2011 06:52 AM, Pierrick Koch wrote:
</div></div><blockquote type="cite"><div><div></div><div class="h5">
<div>Hi everyone, </div>
<div>
<div><br>
</div>
<div>I am looking for a Python method to link/append/import objects
in Blender that would give me back some info about what has been
appended (in the best case a list of the imported objects instances)... </div>
<div><br>
</div>
<div>For instance: let say that in a .blend file I have a car made of
the main structure which contain 4 wheels. </div>
<div>Code:</div>
<div>bpy.ops.wm.link_append(directory="/home/pierrick/atrv.blend/Object",
link=False, </div>
<div> files=[{'name': 'ATRV'}, {'name': 'Wheel.4'}, {'name':
'Wheel.3'}, {'name': 'Wheel.2'}, {'name': 'Wheel.1'}])</div>
<div><br>
</div>
<div>if there was already an object called ATRV, my car will be
renamed ATRV.001, </div>
<div>it would be nice to get an instance of the objects, to avoid
pasing by bpy.data.object </div>
<div><br>
</div>
<div>Same with collada: it would be amazing if: </div>
<div>Code:</div>
<div>bpy.ops.wm.collada_import(filepath="/home/pierrick/atrv.dae")</div>
<div><br>
</div>
<div>could return something like: </div>
<div>Code:</div>
<div>you_just_imported = { </div>
<div> 'ATRV': [ </div>
<div> 'Wheel1', </div>
<div> 'Wheel2', </div>
<div> 'Wheel3', </div>
<div> 'Wheel4' </div>
<div> ] </div>
<div>}</div>
<div><br>
</div>
<div><br>
</div>
<div>Where the string are the real-name of the object in the Blender
instance. </div>
<div>With .001 if there was already another object with the same name
in the scene. </div>
<div><br>
</div>
<div>... </div>
<div>In fact, I'm working on Robotics <a href="http://wiki.blender.org/index.php/Robotics:Contents" target="_blank">http://wiki.blender.org/index.php/Robotics:Contents</a> </div>
<div><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> </div>
<div><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> </div>
<div><a href="http://www.openrobots.org/wiki/morse" target="_blank">http://www.openrobots.org/wiki/morse</a> </div>
<div>... </div>
<div><br>
</div>
<div>Any idea? shall I open an issue for that? </div>
<div>Cheers,</div>
</div>
<div><br>
</div>
<div>Pierrick</div>
<div><br>
</div>
<div>= This message is cross-posted on <a href="http://www.blender.org/forum/viewtopic.php?t=20112" target="_blank">http://www.blender.org/forum/viewtopic.php?t=20112</a> =</div>
</div></div><pre><fieldset></fieldset>
_______________________________________________
Robotics mailing list
<a href="mailto:Robotics@blender.org" target="_blank">Robotics@blender.org</a>
<a href="http://lists.blender.org/mailman/listinfo/robotics" target="_blank">http://lists.blender.org/mailman/listinfo/robotics</a>
</pre>
</blockquote>
<br><font color="#888888">
<br>
<pre cols="72">--
Gilberto Echeverria
Research Engineer
Robotics and Interactions Group (RIS)
LAAS/CNRS, Toulouse
+33 (0)5 61 33 78 95</pre>
</font></div>
<br>_______________________________________________<br>
Robotics mailing list<br>
<a href="mailto:Robotics@blender.org">Robotics@blender.org</a><br>
<a href="http://lists.blender.org/mailman/listinfo/robotics" target="_blank">http://lists.blender.org/mailman/listinfo/robotics</a><br>
<br></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>