pythonblenderbpy

Get object array in blender python script


I am creating my simple game engine with C++ and OpenGL ES3, so I am not a python or blender developer I just use blender for creating low poly models now I wanna using blender as a levels editor so after some researches I created a simple exporter which export the scene to a XML file and it worked fine, My post in blender exchange. I am using instances in my engine so I wanna create array of the same object in blender and export the matrix and count so if I create an array modifier how could I get data for the instances.


Solution

  • I found the solution: create link copy of the object then iterate through bpy.data.meshes then found the mesh owner using this script

    mesh_owners = {}
    for ob in bpy.data.objects:
    if ob.type == 'MESH':
        mesh_owners.setdefault(ob.data, []).append(ob)
    

    Thanks for How to access mesh data of an object in a script?