[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1066] contrib/py/scripts/addons/ mesh_seam_from_uv_isles.py: matching Projects pages with Contrib content
Brendon Murphy
meta.androcto1 at gmail.com
Sun Sep 19 16:15:16 CEST 2010
Revision: 1066
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=1066
Author: meta-androcto
Date: 2010-09-19 16:15:16 +0200 (Sun, 19 Sep 2010)
Log Message:
-----------
matching Projects pages with Contrib content
Added Paths:
-----------
contrib/py/scripts/addons/mesh_seam_from_uv_isles.py
Added: contrib/py/scripts/addons/mesh_seam_from_uv_isles.py
===================================================================
--- contrib/py/scripts/addons/mesh_seam_from_uv_isles.py (rev 0)
+++ contrib/py/scripts/addons/mesh_seam_from_uv_isles.py 2010-09-19 14:15:16 UTC (rev 1066)
@@ -0,0 +1,100 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# 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.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+bl_addon_info = {
+ 'name': 'Mesh: Seam from uv isles',
+ 'author': 'Fredrik Hansson',
+ 'version': '1.01 2010/08/25',
+ 'blender': (2, 5, 3),
+ 'location': 'UV/Image editor> UVs > Seam from UV isles ',
+ 'warning': '', # used for warning icon and text in addons panel
+ 'description': 'Marks seams based on UV isles',
+ 'wiki_url': 'http://wiki.blender.org/index.php/Extensions:2.5/Py/'\
+ 'Scripts/Modeling/Seams_from_uv_isles' ,
+ 'tracker_url': 'https://projects.blender.org/tracker/index.php?'\
+ 'func=detail&aid=22929&group_id=153&atid=467',
+ 'category': 'Mesh'}
+
+import bpy
+
+def main(context):
+ obj = context.active_object
+ mesh = obj.data
+
+ if not obj or obj.type != 'MESH':
+ print("no active Mesh")
+ return
+ if not mesh.uv_textures.active:
+ print("no active UV Texture")
+ return
+ bpy.ops.object.mode_set(mode='OBJECT')
+
+
+ uvtex=mesh.uv_textures.active.data
+
+ wrap_q = [1,2,3,0]
+ wrap_t = [1,2,0]
+ edge_uvs = {}
+
+ for i,uvface in enumerate(uvtex):
+ f=mesh.faces[i]
+ f_uv = [(round(uv[0], 6), round(uv[1], 6)) for uv in uvface.uv]
+ f_vi = [vertices for vertices in f.vertices]
+ for i, key in enumerate(f.edge_keys):
+ if len(f.vertices)==3:
+ uv1, uv2 = f_uv[i], f_uv[wrap_t[i]]
+ vi1, vi2 = f_vi[i], f_vi[wrap_t[i]]
+ else: # quad
+ uv1, uv2 = f_uv[i], f_uv[wrap_q[i]]
+ vi1, vi2 = f_vi[i], f_vi[wrap_q[i]]
+
+ if vi1 > vi2: vi1,uv1,uv2 = vi2,uv2,uv1
+
+ edge_uvs.setdefault(key, []).append((uv1, uv2))
+
+ for ed in mesh.edges:
+ if(len(set(edge_uvs[ed.key])) > 1):
+ ed.use_seam=1
+
+ bpy.ops.object.mode_set(mode='EDIT')
+
+class UvIsleSeamsOperator(bpy.types.Operator):
+ ''''''
+ bl_idname = "mesh.seam_from_uv_isles"
+ bl_label = "Seams from UV isles"
+ bl_options = {'REGISTER', 'UNDO'}
+
+# def poll(self, context):
+# obj = context.active_object
+# return (obj and obj.type == 'MESH')
+
+ def execute(self, context):
+ main(context)
+ return {'FINISHED'}
+
+def uvseam_menu_function(self, context):
+ self.layout.operator(UvIsleSeamsOperator.bl_idname,text="Seams from UV isles",icon='PLUGIN')
+
+def register():
+ bpy.types.IMAGE_MT_uvs.append(uvseam_menu_function)
+
+def unregister():
+ bpy.types.IMAGE_MT_uvs.remove(uvseam_menu_function)
+
+if __name__ == "__main__":
+ register()
\ No newline at end of file
More information about the Bf-extensions-cvs
mailing list