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:
Diffstat (limited to 'release/scripts/op/uvcalc_follow_active.py')
-rw-r--r--release/scripts/op/uvcalc_follow_active.py37
1 files changed, 17 insertions, 20 deletions
diff --git a/release/scripts/op/uvcalc_follow_active.py b/release/scripts/op/uvcalc_follow_active.py
index c8a13441048..9f809dd39f8 100644
--- a/release/scripts/op/uvcalc_follow_active.py
+++ b/release/scripts/op/uvcalc_follow_active.py
@@ -26,10 +26,10 @@ import bpy
def extend(obj, operator, EXTEND_MODE):
me = obj.data
- me_verts = me.verts
+ me_verts = me.vertices
# script will fail without UVs
- if not me.active_uv_texture:
- me.add_uv_texture()
+ if not me.uv_textures:
+ me.uv_textures.new()
# Toggle Edit mode
@@ -54,20 +54,20 @@ def extend(obj, operator, EXTEND_MODE):
# assume a quad
return [(vi[0], vi[1]), (vi[1], vi[2]), (vi[2], vi[3]), (vi[3], vi[0])]
- vidx_source = face_source.verts
- vidx_target = face_target.verts
+ vidx_source = face_source.vertices
+ vidx_target = face_target.vertices
- faceUVsource = me.active_uv_texture.data[face_source.index]
+ faceUVsource = me.uv_textures.active.data[face_source.index]
uvs_source = [faceUVsource.uv1, faceUVsource.uv2, faceUVsource.uv3, faceUVsource.uv4]
- faceUVtarget = me.active_uv_texture.data[face_target.index]
+ faceUVtarget = me.uv_textures.active.data[face_target.index]
uvs_target = [faceUVtarget.uv1, faceUVtarget.uv2, faceUVtarget.uv3, faceUVtarget.uv4]
# vertex index is the key, uv is the value
- uvs_vhash_source = dict([(vindex, uvs_source[i]) for i, vindex in enumerate(vidx_source)])
+ uvs_vhash_source = {vindex: uvs_source[i] for i, vindex in enumerate(vidx_source)}
- uvs_vhash_target = dict([(vindex, uvs_target[i]) for i, vindex in enumerate(vidx_target)])
+ uvs_vhash_target = {vindex: uvs_target[i] for i, vindex in enumerate(vidx_target)}
edge_idxs_source = face_edge_vs(vidx_source)
edge_idxs_target = face_edge_vs(vidx_target)
@@ -138,15 +138,15 @@ def extend(obj, operator, EXTEND_MODE):
uvs_vhash_target[edgepair_outer_target[iA]][:] = uvs_vhash_source[edgepair_inner_source[1]] + (uvs_vhash_source[edgepair_inner_source[1]] - uvs_vhash_source[edgepair_outer_source[0]])
- if me.active_uv_texture == None:
- me.add_uv_texture
+ if not me.uv_textures:
+ me.uv_textures.new()
face_act = me.faces.active
if face_act == -1:
operator.report({'ERROR'}, "No active face.")
return
- face_sel = [f for f in me.faces if len(f.verts) == 4 and f.selected]
+ face_sel = [f for f in me.faces if len(f.vertices) == 4 and f.select]
face_act_local_index = -1
for i, f in enumerate(face_sel):
@@ -177,11 +177,9 @@ def extend(obj, operator, EXTEND_MODE):
except:
edge_faces[edkey] = [i]
- #SEAM = me.edges.seam
-
if EXTEND_MODE == 'LENGTH':
- edge_loops = me.edge_loops(face_sel, [ed.key for ed in me.edges if ed.seam])
- me_verts = me.verts
+ edge_loops = me.edge_loops_from_faces(face_sel, [ed.key for ed in me.edges if ed.use_seam])
+ me_verts = me.vertices
for loop in edge_loops:
looplen = [0.0]
for ed in loop:
@@ -192,7 +190,7 @@ def extend(obj, operator, EXTEND_MODE):
# remove seams, so we dont map accross seams.
for ed in me.edges:
- if ed.seam:
+ if ed.use_seam:
# remove the edge pair if we can
try:
del edge_faces[ed.key]
@@ -249,7 +247,8 @@ class FollowActiveQuads(bpy.types.Operator):
description="Method to space UV edge loops",
default="LENGTH")
- def poll(self, context):
+ @classmethod
+ def poll(cls, context):
obj = context.active_object
return (obj is not None and obj.type == 'MESH')
@@ -263,12 +262,10 @@ menu_func = (lambda self, context: self.layout.operator(FollowActiveQuads.bl_idn
def register():
- bpy.types.register(FollowActiveQuads)
bpy.types.VIEW3D_MT_uv_map.append(menu_func)
def unregister():
- bpy.types.unregister(FollowActiveQuads)
bpy.types.VIEW3D_MT_uv_map.remove(menu_func)
if __name__ == "__main__":