I would like to know how to instance objects in a script. For the sapling script for example. Instead of having each leaf have a different mesh, just make it use one “leaves” mesh and rotate and scale it a bit randomly for each instance. But each instance should have a precise position, not a random one. (no leaves on trunk …)
You can’t instance an object, but you can instance a datablock. In your example, the mesh of the leaf would be the datablock. The object is linked to the datablock. So each unique object can be linked to a shared datablock. Thus it is possible to do what you are asking.
Lets assume you have 3 cubes in the scene an want them all to share the same mesh from cube #1.
import bpy # You can fetch these objects or create them as new. ob1 = bpy.data.objects("Cube1") ob2 = bpy.data.objects("Cube2") ob3 = bpy.data.objects("Cube3") #Get the mesh from cube #1. mesh1 = ob1.data. #Assign the mesh to cube #2 and cube #3. ob2.data = mesh1 ob3.data = mesh1 #Now you have 'instanced' meshes with unique objects that can have their own LOC/ROT/SCALE and even material.
That is useful…why didn’t i think of this when I was making my voxel particle thingy.With this i can save file size and execution time and each voxel can have different material too.
Thanks for your answer atom, sorry for the late reply, i had some troubles in the last days…
I’ll try it these week as soon as i have time