merge 17122:17206
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
# Tooltip: 'Export to DirectX text file format format for XNA Animation Component Library.'
|
||||
"""
|
||||
__author__ = "vertex color exporting feature is added by mnemoto (original:minahito (original:Arben (Ben) Omari))"
|
||||
__url__ = ("blender", "elysiun", "Adjuster's site http://sunday-lab.blogspot.com/, Author's site http://www.omariben.too.it","Adjuster's site http://ex.homeunix.net/")
|
||||
__url__ = ("blender.org", "blenderartists.org", "Adjuster's site http://sunday-lab.blogspot.com/, Author's site http://www.omariben.too.it","Adjuster's site http://ex.homeunix.net/")
|
||||
__version__ = "3.1"
|
||||
|
||||
__bpydoc__ = """\
|
||||
|
||||
@@ -2952,7 +2952,7 @@ def write_ui():
|
||||
#fbx_ui_write('/test.fbx')
|
||||
break
|
||||
|
||||
Draw.UIBlock(fbx_ui)
|
||||
Draw.UIBlock(fbx_ui, 0)
|
||||
|
||||
|
||||
# GLOBALS.clear()
|
||||
|
||||
@@ -678,7 +678,7 @@ def write_ui(filename):
|
||||
|
||||
Draw.Label('Blender Objects as OBJ:', ui_x+9, ui_y+59, 220, 20)
|
||||
Draw.BeginAlign()
|
||||
EXPORT_BLEN_OBS = Draw.Toggle('Objects', EVENT_REDRAW, ui_x+9, ui_y+40, 60, 20, EXPORT_BLEN_OBS.val, 'Export blender objects as "OBJ objects".', do_split)
|
||||
EXPORT_BLEN_OBS = Draw.Toggle('Objects', EVENT_REDRAW, ui_x+9, ui_y+39, 60, 20, EXPORT_BLEN_OBS.val, 'Export blender objects as "OBJ objects".', do_split)
|
||||
EXPORT_GROUP_BY_OB = Draw.Toggle('Groups', EVENT_REDRAW, ui_x+69, ui_y+39, 60, 20, EXPORT_GROUP_BY_OB.val, 'Export blender objects as "OBJ Groups".', do_split)
|
||||
EXPORT_GROUP_BY_MAT = Draw.Toggle('Material Groups', EVENT_REDRAW, ui_x+129, ui_y+39, 100, 20, EXPORT_GROUP_BY_MAT.val, 'Group by materials.', do_split)
|
||||
Draw.EndAlign()
|
||||
@@ -694,7 +694,7 @@ def write_ui(filename):
|
||||
|
||||
# hack so the toggle buttons redraw. this is not nice at all
|
||||
while GLOBALS['EVENT'] not in (EVENT_EXIT, EVENT_EXPORT):
|
||||
Draw.UIBlock(obj_ui)
|
||||
Draw.UIBlock(obj_ui, 0)
|
||||
|
||||
if GLOBALS['EVENT'] != EVENT_EXPORT:
|
||||
return
|
||||
|
||||
@@ -878,7 +878,7 @@ def load_obj_ui(filepath, BATCH_LOAD= False):
|
||||
|
||||
# hack so the toggle buttons redraw. this is not nice at all
|
||||
while GLOBALS['EVENT'] not in (EVENT_EXIT, EVENT_IMPORT):
|
||||
Draw.UIBlock(obj_ui)
|
||||
Draw.UIBlock(obj_ui, 0)
|
||||
|
||||
if GLOBALS['EVENT'] != EVENT_IMPORT:
|
||||
return
|
||||
|
||||
@@ -53,7 +53,7 @@ def dirName(path):
|
||||
# order dosnt matter for loc/size/rot
|
||||
# right handed rotation
|
||||
# angles are in radians
|
||||
# rotation first defines axis then ammount in deg
|
||||
# rotation first defines axis then ammount in radians
|
||||
|
||||
|
||||
|
||||
@@ -1782,7 +1782,7 @@ def importTransform(node, ancestry):
|
||||
bpyob.setMatrix( getFinalMatrix(node, None, ancestry) )
|
||||
|
||||
|
||||
def load_web3d(path, PREF_FLAT=False, PREF_CIRCLE_DIV=16):
|
||||
def load_web3d(path, PREF_FLAT=False, PREF_CIRCLE_DIV=16, HELPER_FUNC = None):
|
||||
|
||||
# Used when adding blender primitives
|
||||
GLOBALS['CIRCLE_DETAIL'] = PREF_CIRCLE_DIV
|
||||
@@ -1818,8 +1818,14 @@ def load_web3d(path, PREF_FLAT=False, PREF_CIRCLE_DIV=16):
|
||||
elif spec=='Transform':
|
||||
# Only use transform nodes when we are not importing a flat object hierarchy
|
||||
if PREF_FLAT==False:
|
||||
importTransform(node, ancestry)
|
||||
|
||||
importTransform(node, ancestry)
|
||||
else:
|
||||
|
||||
# Note, include this function so the VRML/X3D importer can be extended
|
||||
# by an external script.
|
||||
if HELPER_FUNC:
|
||||
HELPER_FUNC(node, ancestry)
|
||||
|
||||
# Add in hierarchy
|
||||
if PREF_FLAT==False:
|
||||
child_dict = {}
|
||||
|
||||
@@ -106,6 +106,12 @@ try:
|
||||
except:
|
||||
struct= chunk= cStringIO= None
|
||||
|
||||
# python 2.3 has no reversed() iterator. this will only work on lists and tuples
|
||||
try:
|
||||
reversed
|
||||
except:
|
||||
def reversed(l): return l[::-1]
|
||||
|
||||
### # Debuggin disabled in release.
|
||||
### # do a search replace to enabe debug prints
|
||||
### DEBUG = False
|
||||
|
||||
@@ -216,7 +216,7 @@ def main():
|
||||
|
||||
# hack so the toggle buttons redraw. this is not nice at all
|
||||
while GLOBALS['EVENT'] == EVENT_REDRAW:
|
||||
Draw.UIBlock(terain_clamp_ui)
|
||||
Draw.UIBlock(terain_clamp_ui, 0)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -143,10 +143,10 @@ def file_callback(filename):
|
||||
normal_key = rvec3d(normal)
|
||||
|
||||
if faceUV:
|
||||
uvcoord= tuple(uv[j])
|
||||
uvcoord= uv[j][0], 1.0-uv[j][1]
|
||||
uvcoord_key = rvec2d(uvcoord)
|
||||
elif vertexUV:
|
||||
uvcoord= tuple(v.uvco)
|
||||
uvcoord= v.uvco[0], 1.0-v.uvco[1]
|
||||
uvcoord_key = rvec2d(uvcoord)
|
||||
|
||||
if vertexColors: color= col[j].r, col[j].g, col[j].b
|
||||
@@ -209,8 +209,8 @@ def file_callback(filename):
|
||||
for j, v in enumerate(f):
|
||||
if f.smooth: normal= rvec3d(v.no)
|
||||
else: normal= no
|
||||
if faceUV: uvcoord= rvec2d(uv[j])
|
||||
elif vertexUV: uvcoord= rvec2d(v.uvco)
|
||||
if faceUV: uvcoord= rvec2d((uv[j][0], 1.0-uv[j][1]))
|
||||
elif vertexUV: uvcoord= rvec2d((v.uvco[0], 1.0-v.uvco[1]))
|
||||
if vertexColors: color= col[j].r, col[j].g, col[j].b
|
||||
|
||||
file.write('%d ' % vdict[v.index][normal, uvcoord, color])
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
"""
|
||||
Name: 'Stanford PLY (*.ply)...'
|
||||
Blender: 241
|
||||
Blender: 248
|
||||
Group: 'Import'
|
||||
Tip: 'Import a Stanford PLY file'
|
||||
"""
|
||||
|
||||
__author__ = 'Bruce Merry'
|
||||
__version__ = '0.92'
|
||||
__version__ = '0.93'
|
||||
__bpydoc__ = """\
|
||||
This script imports Stanford PLY files into Blender. It supports per-vertex
|
||||
normals, and per-face colours and texture coordinates.
|
||||
@@ -35,20 +35,20 @@ Run this script from "File->Import" and select the desired PLY file.
|
||||
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
# Updated by Campbell Barton AKA Ideasman, 10% faster code.
|
||||
# 20th Oct 2008, 0.93 - Updated by Campbell Barton AKA ideasman42, use Mesh rather then NMesh, dont import normals, vcolors work again.
|
||||
# Updated by Campbell Barton AKA Ideasman42, 10% faster code.
|
||||
|
||||
# Portions of this code are taken from mod_meshtools.py in Blender
|
||||
# 2.32.
|
||||
|
||||
import Blender
|
||||
try:
|
||||
import re, struct, StringIO
|
||||
import re, struct
|
||||
except:
|
||||
struct= None
|
||||
|
||||
class element_spec:
|
||||
name = ''
|
||||
count = 0
|
||||
class element_spec(object):
|
||||
__slots__ = 'name', 'count', 'properties'
|
||||
def __init__(self, name, count):
|
||||
self.name = name
|
||||
self.count = count
|
||||
@@ -64,10 +64,8 @@ class element_spec:
|
||||
if p.name == name: return i
|
||||
return -1
|
||||
|
||||
class property_spec:
|
||||
name = ''
|
||||
list_type = ''
|
||||
numeric_type = ''
|
||||
class property_spec(object):
|
||||
__slots__ = 'name', 'list_type', 'numeric_type'
|
||||
def __init__(self, name, list_type, numeric_type):
|
||||
self.name = name
|
||||
self.list_type = list_type
|
||||
@@ -117,14 +115,17 @@ class property_spec:
|
||||
else:
|
||||
return self.read_format(format, 1, self.numeric_type, stream)[0]
|
||||
|
||||
class object_spec:
|
||||
class object_spec(object):
|
||||
__slots__ = 'specs'
|
||||
'A list of element_specs'
|
||||
specs = []
|
||||
|
||||
def __init__(self):
|
||||
self.specs = []
|
||||
|
||||
def load(self, format, stream):
|
||||
return dict([(i.name,[i.load(format, stream) for j in xrange(i.count) ]) for i in self.specs])
|
||||
|
||||
'''
|
||||
# Longhand for above LC
|
||||
answer = {}
|
||||
for i in self.specs:
|
||||
answer[i.name] = []
|
||||
@@ -176,7 +177,7 @@ def read(filename):
|
||||
if (len(tokens) < 3):
|
||||
print 'Invalid format line'
|
||||
return None
|
||||
if (tokens[1] not in format_specs.keys()):
|
||||
if (tokens[1] not in format_specs): # .keys()): # keys is implicit
|
||||
print 'Unknown format', tokens[1]
|
||||
return None
|
||||
if (tokens[2] != version):
|
||||
@@ -209,115 +210,132 @@ def read(filename):
|
||||
|
||||
return (obj_spec, obj);
|
||||
|
||||
|
||||
def add_face(vertices, varr, indices, uvindices, colindices):
|
||||
face = Blender.NMesh.Face([varr[i] for i in indices])
|
||||
for index in indices:
|
||||
vertex = vertices[index];
|
||||
|
||||
if uvindices:
|
||||
face.uv.append((vertex[uvindices[0]], 1.0 - vertex[uvindices[1]]))
|
||||
face.mode &= ~Blender.NMesh.FaceModes.TEX
|
||||
if colindices:
|
||||
if not uvindices: face.uv.append((0, 0)) # Force faceUV
|
||||
face.col.append(Blender.NMesh.Col(vertex[colindices[0]], vertex[colindices[1]], vertex[colindices[2]], 255))
|
||||
face.mode &= ~Blender.NMesh.FaceModes.TEX
|
||||
return face
|
||||
|
||||
def filesel_callback(filename):
|
||||
def load_ply(filename):
|
||||
t = Blender.sys.time()
|
||||
(obj_spec, obj) = read(filename)
|
||||
obj_spec, obj = read(filename)
|
||||
if obj == None:
|
||||
print 'Invalid file'
|
||||
return
|
||||
vmap = {}
|
||||
varr = []
|
||||
uvindices = None
|
||||
noindices = None
|
||||
colindices = None
|
||||
|
||||
uvindices = colindices = None
|
||||
# noindices = None # Ignore normals
|
||||
|
||||
for el in obj_spec.specs:
|
||||
if el.name == 'vertex':
|
||||
vindices = vindices_x, vindices_y, vindices_z = (el.index('x'), el.index('y'), el.index('z'))
|
||||
if el.index('nx') >= 0 and el.index('ny') >= 0 and el.index('nz') >= 0:
|
||||
noindices = (el.index('nx'), el.index('ny'), el.index('nz'))
|
||||
if el.index('s') >= 0 and el.index('t') >= 0:
|
||||
uvindices = (el.index('s'), el.index('t'))
|
||||
if el.index('red') >= 0 and el.index('green') and el.index('blue') >= 0:
|
||||
colindices = (el.index('red'), el.index('green'), el.index('blue'))
|
||||
# noindices = (el.index('nx'), el.index('ny'), el.index('nz'))
|
||||
# if -1 in noindices: noindices = None
|
||||
uvindices = (el.index('s'), el.index('t'))
|
||||
if -1 in uvindices: uvindices = None
|
||||
colindices = (el.index('red'), el.index('green'), el.index('blue'))
|
||||
if -1 in colindices: colindices = None
|
||||
elif el.name == 'face':
|
||||
findex = el.index('vertex_indices')
|
||||
|
||||
mesh_faces = []
|
||||
mesh_uvs = []
|
||||
mesh_colors = []
|
||||
|
||||
def add_face(vertices, indices, uvindices, colindices):
|
||||
mesh_faces.append(indices)
|
||||
if uvindices: mesh_uvs.append([ (vertices[index][uvindices[0]], 1.0 - vertices[index][uvindices[1]]) for index in indices])
|
||||
if colindices: mesh_colors.append([ (vertices[index][colindices[0]], vertices[index][colindices[1]], vertices[index][colindices[2]]) for index in indices])
|
||||
|
||||
|
||||
if uvindices or colindices:
|
||||
# If we have Cols or UVs then we need to check the face order.
|
||||
add_face_simple = add_face
|
||||
|
||||
|
||||
mesh = Blender.NMesh.GetRaw()
|
||||
NMVert = Blender.NMesh.Vert
|
||||
for v in obj['vertex']:
|
||||
|
||||
if noindices > 0:
|
||||
x,y,z,nx,ny,nz = vkey =\
|
||||
(v[vindices_x], v[vindices_y], v[vindices_z],\
|
||||
v[noindices[0]], v[noindices[1]], v[noindices[2]])
|
||||
else:
|
||||
x,y,z = vkey = (v[vindices_x], v[vindices_y], v[vindices_z])
|
||||
#if not vmap.has_key(vkey):
|
||||
try: # try uses 1 less dict lookup
|
||||
varr.append(vmap[vkey])
|
||||
except:
|
||||
nmv = NMVert(vkey[0], vkey[1], vkey[2])
|
||||
mesh.verts.append(nmv)
|
||||
if noindices > 0:
|
||||
nmv.no[0] = vkey[3]
|
||||
nmv.no[1] = vkey[4]
|
||||
nmv.no[2] = vkey[5]
|
||||
vmap[vkey] = nmv
|
||||
varr.append(vmap[vkey])
|
||||
# EVIL EEKADOODLE - face order annoyance.
|
||||
def add_face(vertices, indices, uvindices, colindices):
|
||||
if len(indices)==4:
|
||||
if indices[2]==0 or indices[3]==0:
|
||||
indices= indices[2], indices[3], indices[0], indices[1]
|
||||
elif len(indices)==3:
|
||||
if indices[2]==0:
|
||||
indices= indices[1], indices[2], indices[0]
|
||||
|
||||
add_face_simple(vertices, indices, uvindices, colindices)
|
||||
|
||||
verts = obj['vertex']
|
||||
|
||||
if 'face' in obj:
|
||||
for f in obj['face']:
|
||||
ind = f[findex]
|
||||
nind = len(ind)
|
||||
if nind <= 4:
|
||||
mesh.faces.append(add_face(verts, varr, ind, uvindices, colindices))
|
||||
len_ind = len(ind)
|
||||
if len_ind <= 4:
|
||||
add_face(verts, ind, uvindices, colindices)
|
||||
else:
|
||||
for j in xrange(nind - 2):
|
||||
mesh.faces.append(add_face(verts, varr, (ind[0], ind[j + 1], ind[j + 2]), uvindices, colindices))
|
||||
|
||||
# Fan fill the face
|
||||
for j in xrange(len_ind - 2):
|
||||
add_face(verts, (ind[0], ind[j + 1], ind[j + 2]), uvindices, colindices)
|
||||
|
||||
del obj # Reclaim memory
|
||||
mesh = Blender.Mesh.New()
|
||||
|
||||
mesh.verts.extend([(v[vindices_x], v[vindices_y], v[vindices_z]) for v in obj['vertex']])
|
||||
|
||||
if mesh_faces:
|
||||
mesh.faces.extend(mesh_faces, smooth=True, ignoreDups=True)
|
||||
|
||||
if uvindices or colindices:
|
||||
if uvindices: mesh.faceUV = True
|
||||
if colindices: mesh.vertexColors = True
|
||||
|
||||
for i, f in enumerate(mesh.faces):
|
||||
if uvindices:
|
||||
ply_uv = mesh_uvs[i]
|
||||
for j, uv in enumerate(f.uv):
|
||||
uv[:] = ply_uv[j]
|
||||
|
||||
if colindices:
|
||||
ply_col = mesh_colors[i]
|
||||
for j, col in enumerate(f.col):
|
||||
col.r, col.g, col.b = ply_col[j]
|
||||
|
||||
mesh.calcNormals()
|
||||
|
||||
'''
|
||||
if noindices:
|
||||
normals = 1
|
||||
else:
|
||||
normals = 0
|
||||
'''
|
||||
|
||||
objname = Blender.sys.splitext(Blender.sys.basename(filename))[0]
|
||||
scn= Blender.Scene.GetCurrent()
|
||||
scn.objects.selected = []
|
||||
|
||||
mesh.name= objname
|
||||
scn.objects.new(mesh)
|
||||
scn.objects.active = scn.objects.new(mesh)
|
||||
|
||||
Blender.Redraw()
|
||||
Blender.Window.DrawProgressBar(1.0, '')
|
||||
print '\nSuccessfully imported ' + Blender.sys.basename(filename) + ' ' + str(Blender.sys.time()-t)
|
||||
|
||||
|
||||
|
||||
print '\nSuccessfully imported "%s" in %.3f sec' % (filename, Blender.sys.time()-t)
|
||||
|
||||
def main():
|
||||
if not struct:
|
||||
Blender.Draw.PupMenu('This importer requires a full python install')
|
||||
msg = 'This importer requires a full python install'
|
||||
if Blender.mode == 'background': print msg
|
||||
else: Blender.Draw.PupMenu(msg)
|
||||
return
|
||||
|
||||
Blender.Window.FileSelector(filesel_callback, 'Import PLY', '*.ply')
|
||||
Blender.Window.FileSelector(load_ply, 'Import PLY', '*.ply')
|
||||
|
||||
if __name__=='__main__':
|
||||
main()
|
||||
|
||||
'''
|
||||
import bpy
|
||||
import os
|
||||
files = os.popen('find /fe/ply -iname "*.ply"').readlines()
|
||||
|
||||
|
||||
|
||||
|
||||
files.sort()
|
||||
tot = len(files)
|
||||
for i, f in enumerate(files):
|
||||
if i < 26 or i > 1000000:
|
||||
continue
|
||||
#if i != 12686:
|
||||
# continue
|
||||
|
||||
f = f.strip()
|
||||
print f, i, tot
|
||||
sce = bpy.data.scenes.new(f.split('/')[-1])
|
||||
bpy.data.scenes.active = sce
|
||||
# Window.
|
||||
load_ply(f)
|
||||
'''
|
||||
@@ -47,6 +47,12 @@ def AngleBetweenVecs(a1,a2):
|
||||
except:
|
||||
return 180.0
|
||||
|
||||
# python 2.3 has no reversed() iterator. this will only work on lists and tuples
|
||||
try:
|
||||
reversed
|
||||
except:
|
||||
def reversed(l): return l[::-1]
|
||||
|
||||
class prettyface(object):
|
||||
__slots__ = 'uv', 'width', 'height', 'children', 'xoff', 'yoff', 'has_parent', 'rot'
|
||||
def __init__(self, data):
|
||||
@@ -451,7 +457,10 @@ PREF_MARGIN_DIV= 512):
|
||||
# Even boxes in groups of 4
|
||||
for d, boxes in even_dict.items():
|
||||
if d < max_int_dimension:
|
||||
boxes.sort(key = lambda a: len(a.children))
|
||||
# py 2.3 compat
|
||||
try: boxes.sort(key = lambda a: len(a.children))
|
||||
except: boxes.sort(lambda a, b: cmp(len(a.children), len(b.children)))
|
||||
|
||||
while len(boxes) >= 4:
|
||||
# print "bar", len(boxes)
|
||||
ok = True
|
||||
|
||||
@@ -61,6 +61,12 @@ def AngleBetweenVecsSafe(a1, a2):
|
||||
except:
|
||||
return 180.0
|
||||
|
||||
# Python 2.3 has no reversed.
|
||||
try:
|
||||
reversed
|
||||
except:
|
||||
def reversed(l): return l[::-1]
|
||||
|
||||
# Copied from blender, we could wrap this! - BKE_curve.c
|
||||
# But probably not toooo bad in python
|
||||
def forward_diff_bezier(q0, q1, q2, q3, pointlist, steps, axis):
|
||||
@@ -266,7 +272,9 @@ class tree:
|
||||
brch.calcData()
|
||||
|
||||
# Sort from big to small, so big branches get priority
|
||||
self.branches_all.sort( key = lambda brch: -brch.bpoints[0].radius )
|
||||
# Py 2.3 dosnt have keywords in sort
|
||||
try: self.branches_all.sort( key = lambda brch: -brch.bpoints[0].radius )
|
||||
except: self.branches_all.sort( lambda brch_a, brch_b: cmp(brch_b.bpoints[0].radius, brch_a.bpoints[0].radius) ) # py2.3
|
||||
|
||||
|
||||
def closestBranchPt(self, co):
|
||||
@@ -1144,7 +1152,8 @@ class tree:
|
||||
|
||||
# Try sorting by other properties! this is ok for now
|
||||
for segments_level_current in segments_level:
|
||||
segments_level_current.sort( key = lambda seg: -(seg.headCo-seg.tailCo).length )
|
||||
try: segments_level_current.sort( key = lambda seg: -(seg.headCo-seg.tailCo).length )
|
||||
except: segments_level_current.sort( lambda a,b: cmp((b.headCo-b.tailCo).length, (a.headCo-a.tailCo).length) ) # py2.3
|
||||
|
||||
for level in xrange(twig_fill_levels):
|
||||
if len(segments_level) > level:
|
||||
@@ -1370,18 +1379,23 @@ class tree:
|
||||
|
||||
# Get the branches based on our selection method!
|
||||
if twig_select_mode==0:
|
||||
branches_sorted.sort( key = lambda brch: brch.getLength())
|
||||
try: branches_sorted.sort( key = lambda brch: brch.getLength())
|
||||
except: branches_sorted.sort( lambda a,b: cmp(a.getLength(),a.getLength()) ) # py2.3
|
||||
elif twig_select_mode==1:
|
||||
branches_sorted.sort( key = lambda brch:-brch.getLength())
|
||||
try: branches_sorted.sort( key = lambda brch:-brch.getLength())
|
||||
except: branches_sorted.sort( lambda a,b: cmp(b.getLength(), a.getLength()) ) # py2.3
|
||||
elif twig_select_mode==2:
|
||||
branches_sorted.sort( key = lambda brch:brch.getStraightness())
|
||||
try: branches_sorted.sort( key = lambda brch:brch.getStraightness())
|
||||
except: branches_sorted.sort( lambda a,b: cmp(a.getStraightness(), b.getStraightness())) # py2.3
|
||||
elif twig_select_mode==3:
|
||||
branches_sorted.sort( key = lambda brch:-brch.getStraightness())
|
||||
try: branches_sorted.sort( key = lambda brch:-brch.getStraightness())
|
||||
except: branches_sorted.sort( lambda a,b: cmp(b.getStraightness(), a.getStraightness())) # py2.3
|
||||
|
||||
factor_int = int(len(self.branches_all) * twig_select_factor)
|
||||
branches_sorted[factor_int:] = [] # remove the last part of the list
|
||||
|
||||
branches_sorted.sort( key = lambda brch: len(brch.bpoints))
|
||||
try: branches_sorted.sort( key = lambda brch: len(brch.bpoints))
|
||||
except: branches_sorted.sort( lambda a,b: cmp(len(a.bpoints), len(b.bpoints)) ) # py2.3
|
||||
|
||||
branches_new = []
|
||||
#for i in xrange(ratio_int):
|
||||
|
||||
Reference in New Issue
Block a user