~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to release/scripts/skin.py

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2005-11-06 12:40:03 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051106124003-3pgs7tcg5rox96xg
Tags: 2.37a-1.1
* Non-maintainer upload.
* Split out parts of 01_SConstruct_debian.dpatch again: root_build_dir
  really needs to get adjusted before the clean target runs - closes: #333958,
  see #288882 for reference

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!BPY
 
2
 
 
3
"""
 
4
Name: 'Bridge/Skin/Loft'
 
5
Blender: 234
 
6
Group: 'Mesh'
 
7
Tooltip: 'Select 2 or more vert loops, then run this script'
 
8
"""
 
9
 
 
10
__author__ = "Campbell Barton AKA Ideasman"
 
11
__url__ = ["http://members.iinet.net.au/~cpbarton/ideasman/", "blender", "elysiun"]
 
12
__version__ = "1.1 2005/06/13"
 
13
 
 
14
__bpydoc__ = """\
 
15
With this script vertex loops can be skinned: faces are created to connect the
 
16
selected loops of vertices.
 
17
 
 
18
Usage:
 
19
 
 
20
In mesh Edit mode select the vertices of the loops (closed paths / curves of
 
21
vertices: circles, for example) that should be skinned, then run this script.
 
22
A pop-up will provide further options.
 
23
 
 
24
Notes:
 
25
 
 
26
If the results of a method chosen from the pop-up are not adequate, undo and try one of the others.
 
27
"""
 
28
 
 
29
 
 
30
# $Id: skin.py,v 1.3 2005/06/13 17:21:30 ianwill Exp $
 
31
#
 
32
# -------------------------------------------------------------------------- 
 
33
# Skin Selected edges 1.0 By Campbell Barton (AKA Ideasman)
 
34
# -------------------------------------------------------------------------- 
 
35
# ***** BEGIN GPL LICENSE BLOCK ***** 
 
36
 
37
# This program is free software; you can redistribute it and/or 
 
38
# modify it under the terms of the GNU General Public License 
 
39
# as published by the Free Software Foundation; either version 2 
 
40
# of the License, or (at your option) any later version. 
 
41
 
42
# This program is distributed in the hope that it will be useful, 
 
43
# but WITHOUT ANY WARRANTY; without even the implied warranty of 
 
44
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 
45
# GNU General Public License for more details. 
 
46
 
47
# You should have received a copy of the GNU General Public License 
 
48
# along with this program; if not, write to the Free Software Foundation, 
 
49
# Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
 
50
 
51
# ***** END GPL LICENCE BLOCK ***** 
 
52
# -------------------------------------------------------------------------- 
 
53
 
 
54
 
 
55
 
 
56
# Made by Ideasman/Campbell 2004/04/25 - ideasman@linuxmail.org
 
57
 
 
58
import Blender
 
59
from Blender import *
 
60
import math
 
61
from math import *
 
62
 
 
63
 
 
64
choice = Draw.PupMenu(\
 
65
'Loft-loop - shortest edge method|\
 
66
Loft-loop - even method|\
 
67
Loft-segment - shortest edge|\
 
68
Loft-segment - even method')
 
69
 
 
70
if choice == 1:
 
71
        arg='A1'
 
72
elif choice == 2:
 
73
        arg='A2'
 
74
elif choice == 3:
 
75
        arg='B1'
 
76
elif choice == 4:
 
77
        arg='B2'
 
78
 
 
79
 
 
80
 
 
81
#================#
 
82
# Math functions #
 
83
#================#
 
84
 
 
85
# Measure 2 points
 
86
def measure(v1, v2):
 
87
  return Mathutils.Vector([v1[0]-v2[0], v1[1] - v2[1], v1[2] - v2[2]]).length
 
88
  
 
89
# Clamp
 
90
def clamp(max, number):
 
91
        while number >= max:
 
92
                number = number - max
 
93
        return number
 
94
 
 
95
#=============================================================#
 
96
# List func that takes the last item and adds it to the front #
 
97
#=============================================================#
 
98
def listRotate(ls):
 
99
        ls.append(ls.pop(0))
 
100
 
 
101
#=================================================================#
 
102
# Recieve a list of locs: [x,y,z] and return the average location #
 
103
#=================================================================#
 
104
def averageLocation(locList):
 
105
        avLoc = [0,0,0]
 
106
        
 
107
        # Loop through x/y/z
 
108
        for coordIdx in [0,1,2]:
 
109
                
 
110
                # Add all the values from 1 of the 3 coords at the avLoc.
 
111
                for loc in locList:
 
112
                        avLoc[coordIdx] += loc[coordIdx]
 
113
                
 
114
                avLoc[coordIdx] = avLoc[coordIdx] / len(locList)        
 
115
        return avLoc
 
116
 
 
117
 
 
118
 
 
119
#=============================#
 
120
# Blender functions/shortcuts #
 
121
#=============================#
 
122
def error(str):
 
123
        Draw.PupMenu('ERROR%t|'+str)
 
124
 
 
125
# Returns a new face that has the same properties as the origional face
 
126
# With no verts though
 
127
def copyFace(face):
 
128
  newFace = NMesh.Face()
 
129
  # Copy some generic properties
 
130
  newFace.mode = face.mode
 
131
  if face.image != None:
 
132
    newFace.image = face.image
 
133
  newFace.flag = face.flag
 
134
  newFace.mat = face.mat
 
135
  newFace.smooth = face.smooth
 
136
  return newFace
 
137
 
 
138
#=============================================#
 
139
# Find a selected vert that 2 faces share.    #
 
140
#=============================================#
 
141
def selVertBetween2Faces(face1, face2):
 
142
        for v1 in face1.v:
 
143
                if v1.sel:
 
144
                        for v2 in face2.v:
 
145
                                if v1 == v2:
 
146
                                        return v1
 
147
        
 
148
        
 
149
#=======================================================#
 
150
# Measure the total distance between all the edges in   #
 
151
# 2 vertex loops                                        #
 
152
#=======================================================#
 
153
def measureVloop(mesh, v1loop, v2loop, surplusFaces, bestSoFar):
 
154
        totalDist = 0
 
155
        
 
156
        # Rotate the vertloops to cycle through each pair.
 
157
        # of faces to compate the distance between the 2 poins
 
158
        for ii in range(len(v1loop)):
 
159
                if ii not in surplusFaces:
 
160
                        # Clamp
 
161
                        v2clampii = ii
 
162
                        while v2clampii >= len(v2loop):
 
163
                                v2clampii -= len(v2loop)
 
164
                        print v2clampii
 
165
                        
 
166
                        V1 = selVertBetween2Faces(mesh.faces[v1loop[ii-1]], mesh.faces[v1loop[ii]])
 
167
                        V2 = selVertBetween2Faces(mesh.faces[v2loop[v2clampii-1]], mesh.faces[v2loop[v2clampii]])
 
168
                        
 
169
                        totalDist += measure(V1, V2)
 
170
                        # Bail out early if not an improvement on previously measured.
 
171
                        if bestSoFar != None and totalDist > bestSoFar:
 
172
                                return totalDist
 
173
        
 
174
        #selVertBetween2Faces(mesh.faces[v2loop[0]], mesh.faces[v2loop[1]])
 
175
        return totalDist
 
176
 
 
177
# Remove the shortest edge from a vert loop
 
178
def removeSmallestFace(mesh, vloop):
 
179
        bestDistSoFar = None
 
180
        bestFIdxSoFar = None
 
181
        for fIdx in vloop:
 
182
                vSelLs = []
 
183
                for v in mesh.faces[fIdx].v:
 
184
                        if v.sel:
 
185
                                vSelLs.append(v)
 
186
                
 
187
                dist = measure(vSelLs[0].co, vSelLs[1].co)
 
188
                
 
189
                if bestDistSoFar == None:
 
190
                        bestDistSoFar = dist
 
191
                        bestFIdxSoFar = fIdx 
 
192
                elif dist < bestDistSoFar:
 
193
                        bestDistSoFar = dist
 
194
                        bestFIdxSoFar = fIdx
 
195
        
 
196
        # Return the smallest face index of the vloop that was sent
 
197
        return bestFIdxSoFar
 
198
 
 
199
 
 
200
#=============================================#
 
201
# Take 2 vert loops and skin them             #
 
202
#=============================================#
 
203
def skinVertLoops(mesh, v1loop, v2loop):
 
204
        
 
205
        
 
206
        #=============================================#
 
207
        # Handle uneven vert loops, this is tricky    #
 
208
        #=============================================#
 
209
        # Reorder so v1loop is always the biggest
 
210
        if len(v1loop) < len(v2loop):
 
211
                v1loop, v2loop = v2loop, v1loop
 
212
        
 
213
        # Work out if the vert loops are equel or not, if not remove the extra faces from the larger
 
214
        surplusFaces = []
 
215
        tempv1loop = v1loop[:]  # strip faces off this one, use it to keep track of which we have taken faces from.
 
216
        if len(v1loop) > len(v2loop):
 
217
                
 
218
                # Even face method.
 
219
                if arg[1] == '2':
 
220
                        remIdx = 0
 
221
                        faceStepping = len(     v1loop) / len(v2loop)
 
222
                        while len(v1loop) - len(surplusFaces) > len(v2loop):
 
223
                                remIdx += faceStepping
 
224
                                surplusFaces.append(tempv1loop[ clamp(len(tempv1loop),remIdx) ]) 
 
225
                                tempv1loop.remove(surplusFaces[-1])
 
226
                
 
227
                # Shortest face
 
228
                elif arg[1] == '1':
 
229
                        while len(v1loop) - len(surplusFaces) > len(v2loop):
 
230
                                surplusFaces.append(removeSmallestFace(mesh, tempv1loop)) 
 
231
                                tempv1loop.remove(surplusFaces[-1])
 
232
                        
 
233
        
 
234
        tempv1loop = None
 
235
        
 
236
        v2loop = optimizeLoopOrdedShortEdge(mesh, v1loop, v2loop, surplusFaces)
 
237
        
 
238
        # make Faces from 
 
239
        lenVloop = len(v1loop)
 
240
        lenSupFaces = len(surplusFaces)
 
241
        fIdx = 0
 
242
        offset = 0
 
243
        while fIdx < lenVloop:
 
244
                
 
245
                face = copyFace( mesh.faces[v1loop[clamp(lenVloop, fIdx+1)]] )
 
246
                
 
247
                if v1loop[fIdx] in surplusFaces:
 
248
                        # Draw a try, this face does not catch with an edge.
 
249
                        # So we must draw a tri and wedge it in.
 
250
                        
 
251
                        # Copy old faces properties
 
252
                        
 
253
                        face.v.append( selVertBetween2Faces(\
 
254
                                mesh.faces[v1loop[clamp(lenVloop, fIdx)]],\
 
255
                                mesh.faces[v1loop[clamp(lenVloop, fIdx+1)]]) )
 
256
                        
 
257
                        face.v.append( selVertBetween2Faces(\
 
258
                                mesh.faces[v1loop[clamp(lenVloop, fIdx+1)]],\
 
259
                                mesh.faces[v1loop[clamp(lenVloop, fIdx+2)]]) )
 
260
                        
 
261
                        #face.v.append( selVertBetween2Faces(\
 
262
                        #mesh.faces[v2loop[clamp(lenVloop - lenSupFaces, (fIdx - offset +1 ))]],\
 
263
                        #mesh.faces[v2loop[clamp(lenVloop - lenSupFaces, (fIdx - offset + 2))]]) )
 
264
                        
 
265
                        face.v.append( selVertBetween2Faces(\
 
266
                                mesh.faces[v2loop[clamp(lenVloop - lenSupFaces, (fIdx - offset))]],\
 
267
                                mesh.faces[v2loop[clamp(lenVloop - lenSupFaces, fIdx - offset + 1)]]) )
 
268
                        
 
269
                        mesh.faces.append(face)                 
 
270
                        
 
271
                        # We need offset to work out how much smaller v2loop is at this current index.
 
272
                        offset+=1               
 
273
                        
 
274
 
 
275
                else:   
 
276
                        # Draw a normal quad between the 2 edges/faces
 
277
                        
 
278
                        face.v.append( selVertBetween2Faces(\
 
279
                                mesh.faces[v1loop[clamp(lenVloop, fIdx)]],\
 
280
                                mesh.faces[v1loop[clamp(lenVloop, fIdx+1)]]) )
 
281
                        
 
282
                        face.v.append( selVertBetween2Faces(\
 
283
                                mesh.faces[v1loop[clamp(lenVloop, fIdx+1)]],\
 
284
                                mesh.faces[v1loop[clamp(lenVloop, fIdx+2)]]) )
 
285
                        
 
286
                        face.v.append( selVertBetween2Faces(\
 
287
                                mesh.faces[v2loop[clamp(lenVloop - lenSupFaces, (fIdx - offset +1 ))]],\
 
288
                                mesh.faces[v2loop[clamp(lenVloop - lenSupFaces, (fIdx - offset + 2))]]) )
 
289
                        
 
290
                        face.v.append( selVertBetween2Faces(\
 
291
                                mesh.faces[v2loop[clamp(lenVloop - lenSupFaces, (fIdx - offset))]],\
 
292
                                mesh.faces[v2loop[clamp(lenVloop - lenSupFaces, fIdx - offset + 1)]]) )
 
293
                        
 
294
                        mesh.faces.append(face)
 
295
                        
 
296
                fIdx +=1
 
297
                
 
298
        return mesh
 
299
 
 
300
 
 
301
 
 
302
#=======================================================#
 
303
# Takes a face and returns the number of selected verts #
 
304
#=======================================================#
 
305
def faceVSel(face):
 
306
        vSel = 0
 
307
        for v in face.v:
 
308
                if v.sel:
 
309
                        vSel +=1
 
310
        return vSel
 
311
 
 
312
 
 
313
 
 
314
 
 
315
#================================================================#
 
316
# This function takes a face and returns its selected vert loop  #
 
317
# it returns a list of face indicies
 
318
#================================================================#
 
319
def vertLoop(mesh, startFaceIdx, fIgLs): # fIgLs is a list of faces to ignore.
 
320
        # Here we store the faces indicies that
 
321
        # are a part of the first vertex loop
 
322
        vertLoopLs = [startFaceIdx]
 
323
 
 
324
        restart = 0
 
325
        while restart == 0:
 
326
                # this keeps the face loop going until its told to stop,
 
327
                # If the face loop does not find an adjacent face then the vert loop has been compleated
 
328
                restart = 1 
 
329
                
 
330
                # Get my selected verts for the active face/edge.
 
331
                selVerts = []
 
332
                for v in mesh.faces[vertLoopLs[-1]].v:
 
333
                        selVerts.append(v)
 
334
                
 
335
                fIdx = 0
 
336
                while fIdx < len(mesh.faces) and restart:
 
337
                        # Not already added to the vert list
 
338
                        if fIdx not in fIgLs + vertLoopLs:
 
339
                                # Has 2 verts selected
 
340
                                if faceVSel(mesh.faces[fIdx]) > 1:
 
341
                                        # Now we need to find if any of the selected verts
 
342
                                        # are shared with our active face. (are we next to ActiveFace)
 
343
                                        for v in mesh.faces[fIdx].v:
 
344
                                                if v in selVerts:
 
345
                                                        vertLoopLs.append(fIdx)
 
346
                                                        restart = 0 # restart the face loop.
 
347
                                                        break
 
348
                                        
 
349
                        fIdx +=1
 
350
                        
 
351
        return vertLoopLs
 
352
 
 
353
 
 
354
 
 
355
 
 
356
#================================================================#
 
357
# Now we work out the optimum order to 'skin' the 2 vert loops   #
 
358
# by measuring the total distance of all edges created,          #
 
359
# test this for every possible series of joins                   # 
 
360
# and find the shortest, Once this is done the                   #
 
361
# shortest dist can be skinned.                                  #
 
362
# returns only the 2nd-reordered vert loop                       #
 
363
#================================================================#
 
364
def optimizeLoopOrded(mesh, v1loop, v2loop):
 
365
        bestSoFar = None
 
366
        
 
367
        # Measure the dist, ii is just a counter
 
368
        for ii in range(len(v1loop)):
 
369
                
 
370
                # Loop twice , Once for the forward test, and another for the revearsed
 
371
                for iii in [None, None]:
 
372
                        dist = measureVloop(mesh, v1loop, v2loop, bestSoFar)
 
373
                        # Initialize the Best distance recorded
 
374
                        if bestSoFar == None or dist < bestSoFar:
 
375
                                bestSoFar = dist
 
376
                                bestv2Loop = v2loop[:]
 
377
                        
 
378
                        # We might have got the vert loop backwards, try the other way
 
379
                        v2loop.reverse()
 
380
                listRotate(v2loop)
 
381
        return bestv2Loop
 
382
        
 
383
        
 
384
#================================================================#
 
385
# Now we work out the optimum order to 'skin' the 2 vert loops   #
 
386
# by measuring the total distance of all edges created,          #
 
387
# test this for every possible series of joins                   # 
 
388
# and find the shortest, Once this is done the                   #
 
389
# shortest dist can be skinned.                                  #
 
390
# returns only the 2nd-reordered vert loop                       #
 
391
#================================================================#
 
392
def optimizeLoopOrdedShortEdge(mesh, v1loop, v2loop, surplusFaces):
 
393
        bestSoFar = None
 
394
        
 
395
        # Measure the dist, ii is just a counter
 
396
        for ii in range(len(v2loop)):
 
397
                
 
398
                # Loop twice , Once for the forward test, and another for the revearsed
 
399
                for iii in [None, None]:
 
400
                        dist = measureVloop(mesh, v1loop, v2loop, surplusFaces, bestSoFar)
 
401
                        print 'dist', dist 
 
402
                        # Initialize the Best distance recorded
 
403
                        if bestSoFar == None or dist < bestSoFar:
 
404
                                bestSoFar = dist
 
405
                                bestv2Loop = v2loop[:]
 
406
                                
 
407
                        
 
408
                        # We might have got the vert loop backwards, try the other way
 
409
                        v2loop.reverse()
 
410
                #v2loop = listRotate(v2loop)
 
411
                listRotate(v2loop)
 
412
        print 'best so far ', bestSoFar
 
413
        return bestv2Loop       
 
414
        
 
415
 
 
416
#==============================#
 
417
#  Find our     vert loop list #
 
418
#==============================#
 
419
# Find a face with 2 verts selected,
 
420
#this will be the first face in out vert loop
 
421
def findVertLoop(mesh, fIgLs): # fIgLs is a list of faces to ignore.
 
422
        
 
423
        startFaceIdx = None
 
424
        
 
425
        fIdx = 0
 
426
        while fIdx < len(mesh.faces):   
 
427
                if fIdx not in fIgLs:
 
428
                        # Do we have an edge?
 
429
                        if faceVSel(mesh.faces[fIdx]) > 1:
 
430
                                # THIS IS THE STARTING FACE.
 
431
                                startFaceIdx = fIdx
 
432
                                break
 
433
                fIdx+=1
 
434
        
 
435
        # Here we access the function that generates the real vert loop
 
436
        if startFaceIdx != None:
 
437
                return vertLoop(mesh, startFaceIdx, fIgLs)
 
438
        else:
 
439
                # We are out'a vert loops, return a None,
 
440
                return None
 
441
 
 
442
#===================================#
 
443
# Get the average loc of a vertloop #
 
444
# This is used when working out the #
 
445
# order to loft an object           #
 
446
#===================================#
 
447
def vLoopAverageLoc(mesh, vertLoop):
 
448
        locList = [] # List of vert locations
 
449
                
 
450
        fIdx = 0
 
451
        while fIdx < len(mesh.faces):   
 
452
                if fIdx in vertLoop:
 
453
                        for v in mesh.faces[fIdx].v:
 
454
                                if v.sel:
 
455
                                        locList.append(v.co)
 
456
                fIdx+=1
 
457
        
 
458
        return averageLocation(locList)
 
459
 
 
460
 
 
461
 
 
462
#=================================================#
 
463
# Vert loop group functions
 
464
 
 
465
def getAllVertLoops(mesh):
 
466
        # Make a chain of vert loops.
 
467
        fIgLs = [] # List of faces to ignore 
 
468
        allVLoops = [findVertLoop(mesh, fIgLs)]
 
469
        while allVLoops[-1] != None:
 
470
                
 
471
                # In future ignore all faces in this vert loop
 
472
                fIgLs += allVLoops[-1]          
 
473
                
 
474
                # Add the new vert loop to the list
 
475
                allVLoops.append( findVertLoop(mesh, fIgLs) )
 
476
        
 
477
        return allVLoops[:-1] # Remove the last Value- None.
 
478
        
 
479
        
 
480
def reorderCircularVLoops(mesh, allVLoops):
 
481
        # Now get a location for each vert loop.
 
482
        allVertLoopLocs = []
 
483
        for vLoop in allVLoops:
 
484
                allVertLoopLocs.append( vLoopAverageLoc(mesh, vLoop) )
 
485
 
 
486
        # We need to find the longest distance between 2 vert loops so we can 
 
487
        reorderedVLoopLocs = []
 
488
 
 
489
        # Start with this one, then find the next closest.
 
490
        # in doing this make a new list called reorderedVloop
 
491
        currentVLoop = 0
 
492
        reorderedVloopIdx = [currentVLoop]
 
493
        newOrderVLoops = [allVLoops[0]] # This is a re-ordered allVLoops
 
494
        while len(reorderedVloopIdx) != len(allVLoops):
 
495
                bestSoFar = None
 
496
                bestVIdxSoFar = None
 
497
                for vLoopIdx in range(len(allVLoops)):
 
498
                        if vLoopIdx not in reorderedVloopIdx + [currentVLoop]:
 
499
                                if bestSoFar == None:
 
500
                                        bestSoFar = measure( allVertLoopLocs[vLoopIdx], allVertLoopLocs[currentVLoop] )
 
501
                                        bestVIdxSoFar = vLoopIdx
 
502
                                else:
 
503
                                        newDist = measure( allVertLoopLocs[vLoopIdx], allVertLoopLocs[currentVLoop] )
 
504
                                        if newDist < bestSoFar:
 
505
                                                bestSoFar = newDist
 
506
                                                bestVIdxSoFar = vLoopIdx
 
507
                
 
508
                reorderedVloopIdx.append(bestVIdxSoFar)
 
509
                reorderedVLoopLocs.append(allVertLoopLocs[bestVIdxSoFar])
 
510
                newOrderVLoops.append( allVLoops[bestVIdxSoFar] ) 
 
511
                
 
512
                # Start looking for the next best fit
 
513
                currentVLoop = bestVIdxSoFar
 
514
        
 
515
        # This is not the locicle place to put this but its convieneint.
 
516
        # Here we find the 2 vert loops that are most far apart
 
517
        # We use this to work out which 2 vert loops not to skin when making an open loft.
 
518
        vLoopIdx = 0
 
519
        # Longest measured so far - 0 dummy.
 
520
        bestSoFar = 0
 
521
        while vLoopIdx < len(reorderedVLoopLocs):
 
522
                
 
523
                # Skin back to the start if needs be, becuase this is a crcular loft
 
524
                toSkin2 = vLoopIdx + 1
 
525
                if toSkin2 == len(reorderedVLoopLocs):
 
526
                        toSkin2 = 0
 
527
                
 
528
                newDist  = measure( reorderedVLoopLocs[vLoopIdx], reorderedVLoopLocs[toSkin2] )
 
529
                
 
530
                if newDist >= bestSoFar:
 
531
                        bestSoFar = newDist
 
532
                        vLoopIdxNotToSkin = vLoopIdx + 1        
 
533
                                
 
534
                vLoopIdx +=1 
 
535
        
 
536
        return newOrderVLoops, vLoopIdxNotToSkin
 
537
 
 
538
 
 
539
is_editmode = Window.EditMode()
 
540
if is_editmode: Window.EditMode(0)
 
541
 
 
542
# Get a mesh and raise errors if we cant
 
543
mesh = None
 
544
if choice == -1:
 
545
        pass
 
546
elif len(Object.GetSelected()) > 0:
 
547
  if Object.GetSelected()[0].getType() == 'Mesh':
 
548
    mesh = Object.GetSelected()[0].getData()
 
549
  else:
 
550
    error('please select a mesh')
 
551
else:
 
552
  error('no mesh object selected')
 
553
 
 
554
time1 = sys.time()
 
555
if mesh != None:
 
556
  Window.WaitCursor(1)
 
557
  allVLoops = getAllVertLoops(mesh)
 
558
  
 
559
  # Re order the vert loops
 
560
  allVLoops, vLoopIdxNotToSkin = reorderCircularVLoops(mesh, allVLoops) 
 
561
  
 
562
  vloopIdx = 0
 
563
  while vloopIdx < len(allVLoops):
 
564
    #print range(len(allVLoops) )
 
565
    #print vloopIdx
 
566
    #print allVLoops[vloopIdx]
 
567
    
 
568
    # Skin back to the start if needs be, becuase this is a crcular loft
 
569
    toSkin2 = vloopIdx + 1
 
570
    if toSkin2 == len(allVLoops):
 
571
      toSkin2 = 0
 
572
 
 
573
    # Circular loft or not?
 
574
    if arg[0] == 'B': # B for open
 
575
      if vloopIdx != vLoopIdxNotToSkin:
 
576
        mesh = skinVertLoops(mesh, allVLoops[vloopIdx], allVLoops[toSkin2])
 
577
    elif arg[0] == 'A': # A for closed
 
578
      mesh = skinVertLoops(mesh, allVLoops[vloopIdx], allVLoops[toSkin2])
 
579
    
 
580
    vloopIdx +=1        
 
581
  
 
582
  mesh.update(1,(mesh.edges != []),0)
 
583
 
 
584
if is_editmode: Window.EditMode(1)
 
585
Window.WaitCursor(0)
 
586
print "skinning time: %.2f" % (sys.time() - time1)