2006-01-31 19:47:52 +00:00
|
|
|
#!BPY
|
|
|
|
""" Registration info for Blender menus: <- these words are ignored
|
|
|
|
Name: 'UVcopy'
|
|
|
|
Blender: 242
|
2006-01-31 20:57:05 +00:00
|
|
|
Group: 'Object'
|
2006-01-31 19:47:52 +00:00
|
|
|
Tip: 'Copy UV coords from a mesh to another that has same vertex indices'
|
|
|
|
"""
|
|
|
|
|
2006-01-31 20:57:05 +00:00
|
|
|
__author__ = "Toni Alatalo, Martin Poirier et. al."
|
2006-01-31 19:47:52 +00:00
|
|
|
__url__ = ("blender", "elysiun",
|
|
|
|
"Script's homepage, http://www.elysiun.com/forum/viewtopic.php?t=14897",
|
|
|
|
"Communicate problems and errors, http://www.elysiun.com/forum/viewtopic.php?t=14897")
|
2006-01-31 20:57:05 +00:00
|
|
|
__version__ = "0.2 01/2006"
|
2006-01-31 19:47:52 +00:00
|
|
|
|
|
|
|
__bpydoc__ = """\
|
|
|
|
This script copies UV coords from a mesh to another (version of the same mesh).
|
|
|
|
"""
|
|
|
|
|
|
|
|
import Blender
|
|
|
|
|
2006-01-31 20:57:05 +00:00
|
|
|
scene = Blender.Scene.GetCurrent()
|
|
|
|
|
|
|
|
unwrapped = scene.getActiveObject()
|
|
|
|
targets = Blender.Object.GetSelected()
|
2006-01-31 19:47:52 +00:00
|
|
|
|
2006-01-31 20:57:05 +00:00
|
|
|
if unwrapped:
|
|
|
|
source = unwrapped.data
|
2006-01-31 19:47:52 +00:00
|
|
|
else:
|
2006-01-31 20:57:05 +00:00
|
|
|
raise RuntimeError, "No active object to copy UVs from."
|
2006-01-31 19:47:52 +00:00
|
|
|
|
2006-01-31 20:57:05 +00:00
|
|
|
if targets:
|
|
|
|
try:
|
|
|
|
targets.remove(unwrapped)
|
|
|
|
except ValueError:
|
|
|
|
print "ob for sourcedata was not in targets, so did not need to remove", unwrapped, targets
|
|
|
|
#try:
|
|
|
|
# target = targets[0].data
|
|
|
|
#except IndexError:
|
|
|
|
if not targets:
|
|
|
|
raise RuntimeError, "no selected object other than the source, hence no target defined."
|
2006-01-31 19:47:52 +00:00
|
|
|
else:
|
2006-01-31 20:57:05 +00:00
|
|
|
raise RuntimeError, "No selected object(s) to copy UVs to."
|
|
|
|
|
|
|
|
if source and targets:
|
|
|
|
for target in targets:
|
|
|
|
target = target.data
|
|
|
|
for i in range(len(target.faces)):
|
|
|
|
target.faces[i].uv = source.faces[i].uv
|
|
|
|
#print "copied to target:", target.name, target.data.faces[i].uv, ", source being:", source.faces[i].uv
|
|
|
|
target.update()
|
2006-01-31 21:01:50 +00:00
|
|
|
print "Copied UV from object " + unwrapped.name + " to object(s) " + str([target.name for target in targets]) + "."
|