1
$\begingroup$

I have a .blend file that has a house group in it:

enter image description here

I'd like my script to be able to extract the house group from that file, then make duplicates of it in the current scene. I want to be able to position the duplicates etc.

The closest I could find is getting the meshes in the .blend file, here: http://www.blender.org/api/blender_python_api_2_72_release/bpy.types.BlendDataLibraries.html

filepath = dir + "/somewhere/myHouseModel.blend";

with bpy.data.libraries.load(filepath) as (data_from, data_to):
    data_to.meshes = data_from.meshes
        for mesh in data_to.meshes:
            if mesh is not None:
                print("Mesh name: %s" % (mesh));
                ...

I suppose I could do something to just extract the meshes and work with that, but it would be nicer to properly link to the group. This is how I had it working manually in a standalone blend scene, so I'd like to mimic it via my python script.

Thank you for any help

$\endgroup$
1
$\begingroup$

This loads group "Head" from file mouth.blend. The group can be added to the scene as a group instance.

with bpy.data.libraries.load("/home/batfinger/3DModels/mouth.blend") as (df, dt):
    dt.groups = ['Head']

In your case you will load group "house00" from file myHouseModel.blend

How to add a group instance is covered here Add a group instance with python

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.