Mesh Data Copier

Ive been trying to find information on how to use the “Mesh Data Copier” script. I have tryed copying data such as material data from one object to another without sucess. The only thing i can find is a Lamp Data Copier on this forum from the search and this page http://www.blender3d.org/cms/Python.382.0.html with a short discription of the scrypt.

If anyone knows how to use this scrypt or where i can find more information that would be apreciated.

Could you be a bit more specific what you want?
If you just want to copy a material between two objects, you can click on the second one, and in materialbuttons (F5) click the [-] button and choose the material on the first one.
It’ll link the two objects to the same material, so if you change one it’ll change the other - to change this click the [2] button (the 2 is the number of links) and confirm the “Make single user” request. It’ll make a copy of the material.

To do it to lots of objects at once, Shift+RMB to select them (or B for border select), and select the one with the material you want to copy last so that it’s “active” (white instead of pink with the default colour theme) - then press L-key for Link and choose Material

What i want is for a mesh which has several materials asigned to various vertex groups, such as a sphere where one half has a wood texture material and the other half has a solid blue material. To copy this material asignment to another sphere. If the second sphere is a duplicate.

so that if i was maskeing a mesh, and duplicated it before assigning the materials, i want all duplicated versions to have same material assignments, but not just a single material per mesh.

I looked at the oops schematic and was not able to change any links in there.

But i was also hopeing to get more information on the script because i think it might be usefull when copying the xy location of object A to object b where object b might be a completly difernt mesh.

Shft-D in edit mode will copy everything. I’ll look at the script and get back to you.

%<

If i Shift D after ive assigned multiple materials it is fine but if i Shift D and then later deside to add materials, i do so with vertex assignment of multiple materials, but the copyed objects dont see this.

These were Shift D objects, but I assigned material after.

http://img54.exs.cx/img54/1729/problemlinkmaterial.jpg

Well since your talking about copying vertex groups as well then I can only assume that the target object (the one you want to set the materials of) has the same geometry as the source. If that’s the case why not just delete the copy and create a new copy from the object that does have the material assignments.

import Blender

def go():
  objs = Blender.Object.GetSelected()
  if len(objs) &lt; 2:
    print "Select at least two objects"
    return
  active = objs[0].getData()
  others = [i.getData() for i in objs[1:]]
  for i in others:
    if len(i.faces) != len(active.faces):
      print "%s has the wrong number of faces" % i.name
      return
  for i in others:
    i.materials = active.materials[:]
    for j in range(len(active.faces)):
      i.faces[j].materialIndex = active.faces[j].materialIndex
  print "Done"

go()

untested, but should work
Select all the meshes, selecting the one you want to copy the material settings from last, then run the script.
Note that if you’ve changed the faces at all (added or removed - moving verts is OK. Edges aren’t though, they’re stored as faces with 2 verts) then it will mess up.

http://www.blender.org/modules/documentation/233PythonDoc/

Did you try Alt D?

OK, I messed with that script for hours and cant get it to work. PM jms and ask him what’s up since I can’t track down any mention of it on his site.

%<

Tryed ALT D and that works all fine if i know ahead of time i want them to be linked. it never realy came across my mind to just delete the copy and start again. Thats an ok option but then i have to reposition, size and maybe mirror all over again.

I havent tryed your scrypt yet because for some reason i cant get any scrypts to add to my menu, im looking into this and will let you know.

Im asumeing now jms made the scrypt, ill try to get a hold of him.

Update: Ok i just tryed the script posted above but it does nothing in the text window when i use ALT P, i did make sure to slect two objects. But to no avail.

Im gona contact jms now reguarding his mesh data copyer

Oops, damnit, I forgot a little bit of the script :x (i said it was untested, didn’t I?)

Try this:

import Blender

def go():
  objs = Blender.Object.GetSelected()
  if len(objs) &lt; 2:
    print "Select at least two objects"
    return
  active = objs[0].getData()
  others = [i.getData() for i in objs[1:]]
  for i in others:
    if len(i.faces) != len(active.faces):
      print "%s has the wrong number of faces" % i.name
      return
  for i in others:
    i.materials = active.materials[:]
    for j in range(len(active.faces)):
      i.faces[j].materialIndex = active.faces[j].materialIndex
    i.update()
  Blender.Redraw()
  print "Done"

go()

BTW: it shouldn’t seem to display anything - it’ll just have a one-line error message or “Done” in the console when it finishes.