4
$\begingroup$

I am trying to link two mesh objects, each one has its own UV mapping, both are using the same texture, how can I link the two objects and keep the UV mapping of both objects? It only keeps the one atm. Or is there a way of copying the entire UV map of the one object and paste it when the objects are linked?

$\endgroup$
  • 1
    $\begingroup$ When you say link, do you mean "join"? If so, then as far as I know, this is not possible. When (or if) you clarify, I'll post an answer. $\endgroup$ – A Wild RolandiXor Jul 31 '14 at 21:57
4
$\begingroup$

You can do this with a very simple python script

# make sure to be in Object mode
# make sure to have two objects selected
import bpy
import bmesh
from mathutils import Matrix
from contextlib import ExitStack

def work():
    C = bpy.context
    if C.mode != 'OBJECT':
        return
    if len(C.selected_objects) < 1:
        print("Must have at least one object selected")
        return
    # read into bmesh safely
    names = []
    with ExitStack() as stack:
        bm = bmesh.new()
        stack.callback(bm.free)
        for o in C.selected_objects:
            if o.type != 'MESH':
                continue
            m = o.matrix_world
            bm.transform(m.inverted())
            bm.from_mesh(o.data)
            bm.transform(m)
            names.append(o.name)
        # write to actual mesh
        mesh = bpy.data.meshes.new('Result')
        object = bpy.data.objects.new('Merge(%s)' % ', '.join(names), mesh)
        bm.to_mesh(mesh)
    C.scene.objects.link(object)
    C.scene.update()

work()

I hope this fulfills your needs, I figure you can easily adapt to even more objects but this script should do what you want. Just copy and paste in into the text editor, select your two objects and hit the "Run Script" button.

EDIT: the script can now handle indefinitly many objects.

$\endgroup$
  • $\begingroup$ It just makes my Blender crash and close =D I made sure to have two objects selected in Object mode =3c $\endgroup$ – Ray Jul 28 '15 at 19:31
  • $\begingroup$ @RayKoopa, I hope I fixed it with the exit. Tell me if not $\endgroup$ – WorldSEnder Jul 29 '15 at 2:16
  • $\begingroup$ It still just closes when running it =3 $\endgroup$ – Ray Jul 29 '15 at 19:14
  • $\begingroup$ @RayKoopa, what objects do you have selected? What Blender version are you running it in? $\endgroup$ – WorldSEnder Jul 29 '15 at 19:14
  • $\begingroup$ That are two normal meshes, with a textured material, in 2.75. =3 I tried it on new meshes, there it works... but not on mine. Well, don't worry, I got around this problem anyway =3 $\endgroup$ – Ray Jul 30 '15 at 16:50
2
$\begingroup$

This isn't possible by definition, as UV maps are object data. By linking object data, you link the UV maps too.
This makes sense, as UVs depend on vertex order.

Instead you could use two UV maps, with different materials for each object.

  1. Transfer UV maps

    1. With one of your objects selected, create a new UV map by clicking the plus button and select it:

      enter image description here

    2. Select both objects so that the one with the other UV map is active, and press CtrlL> Transfer UV maps. This will copy the selected UV map from the active object into the selected UV map slot in the selected objects.

  2. Now that you have both UV maps on one object, link the other object to the one with both UV maps (CtrlL> Link object data).

  3. You can either use separate materials linked to the object instead of the object data, or you could use on material which mixes based on the object index.

    • Separate materials

      1. Set the material link to Object for each object. This will make the specified material be used on that object, regardless of what data is linked.

        enter image description here

      2. Create a material with a UV map node to specify which UV map to use, and specify it as the material for one object.

      3. Specify it for the other object and press the little number to make a copy of it:

        enter image description here

      4. Change the selected UV map in the UV map node. You should now have linked objects with separate materials, which use separate UV maps:

        enter image description here

Example .blend

$\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.