X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=utils%2FModeller%2Fuv_export_svg.py;h=af703793cbef6da21065c87815508c71b1758f09;hb=030742fa4ae7d99facb517381da71fa404c4ee2b;hp=1af31a5a67ed3ec60249192eb6608d1c4f7e0118;hpb=7ccdc1081a0196db55472fb35c4ad9a944fcce16;p=flightgear.git diff --git a/utils/Modeller/uv_export_svg.py b/utils/Modeller/uv_export_svg.py index 1af31a5a6..af703793c 100644 --- a/utils/Modeller/uv_export_svg.py +++ b/utils/Modeller/uv_export_svg.py @@ -8,7 +8,7 @@ # """ __author__ = "Melchior FRANZ < mfranz # aon : at >" -__url__ = "http://members.aon.at/mfranz/flightgear/" +__url__ = ["http://www.flightgear.org/", "http://cvs.flightgear.org/viewvc/source/utils/Modeller/uv_export_svg.py"] __version__ = "0.1" __bpydoc__ = """\ Saves the UV mappings of all selected objects to an SVG file. The uv_import_svg.py @@ -16,8 +16,27 @@ script can be used to re-import such a file. Each object and each group of adjac faces therein will be made a separate SVG group. """ -FILL_COLOR = '' # 'yellow' or '#ffa000' e.g. for uni-color, empty string for random color -ID_SEPARATOR = '_.._' +#-------------------------------------------------------------------------------- +# Copyright (C) 2008 Melchior FRANZ < mfranz # aon : at > +# +# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#-------------------------------------------------------------------------------- + + +FILL_COLOR = None # 'yellow' or '#ffa000' e.g. for uni-color, None for random color +ID_SEPARATOR = '_.:._' import Blender, BPyMessages, sys, random @@ -46,15 +65,15 @@ class UVFaceGroups: face = faces.popitem()[1] group = [face] for c in face.uv: - uvcoords[(c[0], c[1])] = True + uvcoords[tuple(c)] = True while True: found = [] for face in faces.itervalues(): for c in face.uv: - if (c[0], c[1]) in uvcoords: + if tuple(c) in uvcoords: for c in face.uv: - uvcoords[(c[0], c[1])] = True + uvcoords[tuple(c)] = True found.append(face) break if not found: @@ -64,11 +83,11 @@ class UVFaceGroups: del faces[face.index] -def hashcolor(name): - random.seed(hash(name)) - c = [random.randint(220, 255), random.randint(120, 220), random.randint(120, 220)] +def stringcolor(string): + random.seed(hash(string)) + c = [random.randint(220, 255), random.randint(120, 240), random.randint(120, 240)] random.shuffle(c) - return "#%02x%02x%02x" % (c[0], c[1], c[2]) + return "#%02x%02x%02x" % tuple(c) def write_svg(path): @@ -77,7 +96,6 @@ def write_svg(path): raise Abort('no image size chosen') size = 1 << (size + 6) - print "exporting to '%s' (size %d) ... " % (path, size), svg = open(path, "w") svg.write('\n') svg.write('\n\n') @@ -99,7 +117,7 @@ def write_svg(path): for meshname, v in objects.iteritems(): objname, mesh = v - color = FILL_COLOR or hashcolor(meshname) + color = FILL_COLOR or stringcolor(meshname) svg.write('\t\n' % (color, objname, objname)) @@ -122,7 +140,6 @@ def write_svg(path): svg.write('\n') svg.close() - print "done." def export(path):