Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Poirier <theeth@yahoo.com>2007-03-26 19:55:23 +0400
committerMartin Poirier <theeth@yahoo.com>2007-03-26 19:55:23 +0400
commitc78947d2d16437ff5430cf115f21a2fceba96e8f (patch)
treea61cca2474fcb2e277b7b3204ecefd4580ec8ed9 /release/scripts/uv_export.py
parent5c760e481114da07ef2ee364bc305bb7716abe8c (diff)
=== Export UV Layout ===
[ #6450 ] Save UV Layout: Overflow Error This error was caused by excentric UV faces being exported (I'm talking things like 3443870976 as UV coord, in a range of 0..1). Edges with extreme coordinates are now ignored (for TGA only, they are exported to SVG) and a warning is printed (at most once) to the console. I chose to still export them to SVG because they don't affect the running time of the script while exporting them to TGA is just insanely long.
Diffstat (limited to 'release/scripts/uv_export.py')
-rw-r--r--release/scripts/uv_export.py55
1 files changed, 32 insertions, 23 deletions
diff --git a/release/scripts/uv_export.py b/release/scripts/uv_export.py
index ccede0d8cc8..80ba295ded8 100644
--- a/release/scripts/uv_export.py
+++ b/release/scripts/uv_export.py
@@ -8,8 +8,8 @@ Tooltip: 'Export the UV face layout of the selected object to a .TGA or .SVG fil
"""
__author__ = "Martin 'theeth' Poirier"
-__url__ = ("http://www.blender.org", "http://www.elysiun.com")
-__version__ = "2.1"
+__url__ = ("http://www.blender.org", "http://blenderartists.org/")
+__version__ = "2.3"
__bpydoc__ = """\
This script exports the UV face layout of the selected mesh object to
@@ -94,6 +94,9 @@ Notes:<br>
# Cleanup code
# Filename handling enhancement and bug fixes
# --------------------------
+# Version 2.3
+# Added check for excentric UVs (only affects TGA)
+# --------------------------
FullPython = False
@@ -107,7 +110,6 @@ except:
from math import *
-
def ExportConfig():
conf = {}
@@ -323,6 +325,8 @@ def write_tgafile(loc2,bitmap,width,height,profondeur):
def UV_Export_TGA(vList, size, wsize, wrap, file):
+ extreme_warning = False
+
minx = 0
miny = 0
scale = 1.0
@@ -366,25 +370,30 @@ def UV_Export_TGA(vList, size, wsize, wrap, file):
step = int(ceil(size*sqrt((co1[0]-co2[0])**2+(co1[1]-co2[1])**2)))
if step:
- for t in range(step):
- x = int(floor((co1[0] + t*(co2[0]-co1[0])/step) * size))
- y = int(floor((co1[1] + t*(co2[1]-co1[1])/step) * size))
-
- if wrap:
- x = x % wrapSize
- y = y % wrapSize
- else:
- x = int ((x - minx) * scale)
- y = int ((y - miny) * scale)
-
- co = x * 1 + y * 1 * size;
-
- img[co] = 0
- if wsize > 1:
- for x in range(-1*wsize + 1,wsize):
- for y in range(-1*wsize,wsize):
- img[co + 1 * x + y * 1 * size] = 0
-
+ try:
+ for t in xrange(step):
+ x = int(floor((co1[0] + t*(co2[0]-co1[0])/step) * size))
+ y = int(floor((co1[1] + t*(co2[1]-co1[1])/step) * size))
+
+ if wrap:
+ x = x % wrapSize
+ y = y % wrapSize
+ else:
+ x = int ((x - minx) * scale)
+ y = int ((y - miny) * scale)
+
+ co = x * 1 + y * 1 * size;
+
+ img[co] = 0
+ if wsize > 1:
+ for x in range(-1*wsize + 1,wsize):
+ for y in range(-1*wsize,wsize):
+ img[co + 1 * x + y * 1 * size] = 0
+ except OverflowError:
+ if not extreme_warning:
+ print "Skipping extremely long UV edges, check your layout for excentric values"
+ extreme_warning = True
+
for v in f:
x = int(v[0] * size)
y = int(v[1] * size)
@@ -485,4 +494,4 @@ if retval:
if bEdit.val and not bEditPath.val:
SetEditorAndExport()
else:
- Export()
+ Export() \ No newline at end of file