#!BPY
""" Registration info for Blender menus: <- these words are ignored
Name: 'UVcoord2mesh'
Blender: 237
Group: 'UV'
Tip: 'Use UV coord to deform selected mesh . It currently only works
a lone face, sorry . '
"""
__author__ = "Jean-Michel Soler (jms)"
__url__ = ("blender", "elysiun",
"Script's homepage, http://jmsoler.free.fr/didacticiel/blender/tutor/python_uv2mesh.htm",
"Communicate problems and errors, http://www.zoo-logique.org/3D.Blender/newsportal/thread.php?group=3D.Blender")
__version__ = "0.1 08/2005"
__bpydoc__ = """\
"""
#----------------------------------------------
# uvcoord2meshr script (c) 08/2005 jean-michel soler
# http://jmsoler.free.fr/didacticiel/blender/tutor/python_uv2mesh.htm
# this script is released under GPL licence
# for the Blender 2.33 scripts distribution
#----------------------------------------------
# Official page :
# http://jmsoler.free.fr/didacticiel/blender/tutor/cpl_uvpainting.htm
# Communicate problems and errors on:
# http://www.zoo-logique.org/3D.Blender/newsportal/thread.php?group=3D.Blender
#----------------------------------------------
#---------------------------------------------
# ce script est proposé sous licence GPL pour etre associe
# a la distribution de Blender 2.33 et suivant
# --------------------------------------------------------------------------
# this script is released under GPL licence
# for the Blender 2.37/2.38 scripts package
# --------------------------------------------------------------------------
# ***** BEGIN GPL LICENSE BLOCK *****
#
# Script copyright (C) 2005: Jean-Michel Soler
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
import Blender
from Blender import NMesh,Object
try :
MESH=Blender.Object.GetSelected()[0].getData()
Blender.Object.GetSelected()[0].setSize(1.0,1.0,1.0)
SF=[s for s in MESH.faces if s.sel==1 or s in MESH.getSelectedFaces()]
prop=1.0
verbose=1
for f in SF:
if f.image:
im=Blender.Image.Get(f.image.name)
if verbose: print
'images :',im
break
if im:
imX,imY = im.getMaxXY()
prop=float(imX)/float(imY)
if verbose: print 'prop : ',prop
for f in SF:
n=0
for v in f.uv:
if verbose: print
'v',v
if verbose: print
'f.v[%s].co'%n,f.v[n].co
f.v[n].co[0]=v[0]*prop
f.v[n].co[1]=v[1]
f.v[n].co[2]=0.0
n+=1
MESH.update()
except :
print "perhaps not a mesh or no object selected ." |