I’m trying to add a sphere to an existing object. When I use this function the object contains only the last defined mesh :
def exist_object (name) :
global me, ob, Struct_name
scn= bpy.data.scenes.active
if (name in Struct_name) : # object exist
me = bpy.data.meshes[name]
ob = Object.Get(name)
ob.select(1)
else :
Struct_name.append(name)
me = bpy.data.meshes.new(name)
ob = scn.objects.new(me,name)
def draw_marker(r,name) :
exist_object(name)
r = Neurofile.readline()
while r.find(‘End of markers’) == -1 :
line = r.split(’,’)
expr = line[0].split()
diameter = expr[4].split(’)’)
me = Mesh.Primitives.Icosphere(2,float(diameter[0]))
ob.LocX = float(expr[1])
ob.LocY = float(expr[2])
ob.LocZ = float(expr[3])*ZShrink
ob.link(me)
r = Neurofile.readline()
Redraw()
I think the problem might be in line ob.link(me). This links mesh to object overriding the old link (old mesh link in this case). You need to add the mesh into currently linked mesh by editing its data.
That you suggest is to read the last indexes of the edges and faces lists of the first mesh, merge the vertex list of the second mesh to the first, and add the index value to the indexes lists of the second edges and faces lists ??
I was thinking to something like that. However, I’m surprised that this function don’t exist in the API. I mean something to merge two meshes. I have noted that the join() function in the object class don’t work also.