[Robotics] Ask for: link/append/import returns object(s) instance(s)

Gilberto Echeverria gilberto.echeverria at laas.fr
Tue May 24 11:05:55 CEST 2011


Hi Pierrick,

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.

For the moment, a possible workaround to find out what objects you have 
just linked would be something like this:

# Deselect all objects in the scene
bpy.ops.object.select_all(DESELECT)
# Import from another file, asking to auto select the new objects:
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'}], autoselect=True)
# Read the list of selected objects
for obj in bpy.context.selected_objects:


Hope this helps. Cheers!
Gilberto


On 05/24/2011 06:52 AM, Pierrick Koch wrote:
> Hi everyone,
>
> 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)...
>
> For instance: let say that in a .blend file I have a car made of the 
> main structure which contain 4 wheels.
> Code:
> 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'}])
>
> if there was already an object called ATRV, my car will be renamed 
> ATRV.001,
> it would be nice to get an instance of the objects, to avoid pasing by 
> bpy.data.object
>
> Same with collada: it would be amazing if:
> Code:
> bpy.ops.wm.collada_import(filepath="/home/pierrick/atrv.dae")
>
> could return something like:
> Code:
> you_just_imported = {
>   'ATRV': [
>     'Wheel1',
>     'Wheel2',
>     'Wheel3',
>     'Wheel4'
>   ]
> }
>
>
> Where the string are the real-name of the object in the Blender instance.
> With .001 if there was already another object with the same name in 
> the scene.
>
> ...
> In fact, I'm working on Robotics 
> http://wiki.blender.org/index.php/Robotics:Contents
> https://github.com/pierriko/morse/blob/master/src/morse/builder/morsebuilder.py#L61 
>
> https://github.com/pierriko/morse/blob/master/examples/morse/scenarii/ros_example.py 
>
> http://www.openrobots.org/wiki/morse
> ...
>
> Any idea? shall I open an issue for that?
> Cheers,
>
> Pierrick
>
> = This message is cross-posted on 
> http://www.blender.org/forum/viewtopic.php?t=20112 =
>
>
> _______________________________________________
> Robotics mailing list
> Robotics at blender.org
> http://lists.blender.org/mailman/listinfo/robotics
>    


-- 
Gilberto Echeverria
Research Engineer
Robotics and Interactions Group (RIS)
LAAS/CNRS, Toulouse
+33 (0)5 61 33 78 95

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.blender.org/pipermail/robotics/attachments/20110524/5fa611e5/attachment.htm 


More information about the Robotics mailing list