[#18082] make uvcalc_follow_active_coords.py bypass the gui and accept arguments when called from another script
from Bill N (slow67) Also made uvcalc_quad_clickproj.py and uvcalc_follow_active_coords.py add UV's if they didn't exist.
This commit is contained in:
@@ -42,28 +42,15 @@ from Blender import *
|
|||||||
import bpy
|
import bpy
|
||||||
import BPyMesh
|
import BPyMesh
|
||||||
|
|
||||||
def extend():
|
def extend(EXTEND_MODE,ob):
|
||||||
sce = bpy.data.scenes.active
|
if EXTEND_MODE == -1:
|
||||||
ob = sce.objects.active
|
|
||||||
|
|
||||||
# print ob, ob.type
|
|
||||||
if ob == None or ob.type != 'Mesh':
|
|
||||||
Draw.PupMenu('ERROR: No mesh object.')
|
|
||||||
return
|
return
|
||||||
|
me = ob.getData(mesh=1)
|
||||||
|
me_verts = me.verts
|
||||||
# Toggle Edit mode
|
# Toggle Edit mode
|
||||||
is_editmode = Window.EditMode()
|
is_editmode = Window.EditMode()
|
||||||
if is_editmode:
|
if is_editmode:
|
||||||
Window.EditMode(0)
|
Window.EditMode(0)
|
||||||
|
|
||||||
me = ob.getData(mesh=1)
|
|
||||||
me_verts = me.verts
|
|
||||||
|
|
||||||
# 0:normal extend, 1:edge length
|
|
||||||
EXTEND_MODE = Draw.PupMenu("Use Face Area%t|Loop Average%x2|None%x0")
|
|
||||||
if EXTEND_MODE == -1:
|
|
||||||
return
|
|
||||||
|
|
||||||
Window.WaitCursor(1)
|
Window.WaitCursor(1)
|
||||||
t = sys.time()
|
t = sys.time()
|
||||||
edge_average_lengths = {}
|
edge_average_lengths = {}
|
||||||
@@ -153,8 +140,7 @@ def extend():
|
|||||||
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]])
|
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 not me.faceUV:
|
if not me.faceUV:
|
||||||
Draw.PupMenu('ERROR: Mesh has no face UV coords.')
|
me.faceUV= True
|
||||||
return
|
|
||||||
|
|
||||||
face_act = me.activeFace
|
face_act = me.activeFace
|
||||||
if face_act == -1:
|
if face_act == -1:
|
||||||
@@ -247,7 +233,22 @@ def extend():
|
|||||||
Window.RedrawAll()
|
Window.RedrawAll()
|
||||||
Window.WaitCursor(0)
|
Window.WaitCursor(0)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
sce = bpy.data.scenes.active
|
||||||
|
ob = sce.objects.active
|
||||||
|
|
||||||
|
# print ob, ob.type
|
||||||
|
if ob == None or ob.type != 'Mesh':
|
||||||
|
Draw.PupMenu('ERROR: No mesh object.')
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 0:normal extend, 1:edge length
|
||||||
|
EXTEND_MODE = Draw.PupMenu("Use Face Area%t|Loop Average%x2|None%x0")
|
||||||
|
extend(EXTEND_MODE,ob)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
extend()
|
main()
|
||||||
|
|
||||||
|
|
||||||
@@ -171,6 +171,9 @@ def main():
|
|||||||
f_uv = f.uv
|
f_uv = f.uv
|
||||||
return [(v.co-face_corner_main, f_uv[i]) for i,v in enumerate(f.v)]
|
return [(v.co-face_corner_main, f_uv[i]) for i,v in enumerate(f.v)]
|
||||||
|
|
||||||
|
if me.faceUV==False:
|
||||||
|
me.faceUV= True
|
||||||
|
|
||||||
coords = [ (co,uv) for f in me.faces if f.sel for co, uv in get_face_coords(f)]
|
coords = [ (co,uv) for f in me.faces if f.sel for co, uv in get_face_coords(f)]
|
||||||
|
|
||||||
coords_orig = [uv.copy() for co, uv in coords]
|
coords_orig = [uv.copy() for co, uv in coords]
|
||||||
@@ -265,3 +268,4 @@ def main():
|
|||||||
if __name__=='__main__':
|
if __name__=='__main__':
|
||||||
main()
|
main()
|
||||||
Window.DrawProgressBar(1.0, '')
|
Window.DrawProgressBar(1.0, '')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user