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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-03-18 00:44:58 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-03-18 00:44:58 +0300
commitd52400bfbd2a7e4d09b5a71bc461a554d232af15 (patch)
tree08815f065fc90aac0ae62ae5f3a89d20e19399e6 /release
parent1ac0d54fea831c485e8e27e8bfa887e15beb58de (diff)
parent28f6d223d079b1e5cb67e3fc22fb7f818deb8dcb (diff)
2.50: svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r18677:19317
Notes: * Sequence transform strip uses G.scene global, this is commented out now, should be fixed. * Etch-a-ton code was most difficult to merge. The files already in 2.5 got merged, but no new files were added. Calls to these files are commented out with "XXX etch-a-ton". editarmature.c and transform_snap.c were complex to merge. Martin, please check? * Game engine compiles and links again here for scons/make/cmake (player still fails to link).
Diffstat (limited to 'release')
-rw-r--r--release/freedesktop/blender.desktop10
-rw-r--r--release/scripts/bpymodules/paths_svg2obj.py178
-rw-r--r--release/scripts/export_fbx.py4
-rw-r--r--release/scripts/export_obj.py2
-rw-r--r--release/scripts/import_dxf.py402
-rw-r--r--release/scripts/import_obj.py4
-rwxr-xr-xrelease/scripts/import_web3d.py2
-rw-r--r--release/scripts/ply_import.py19
-rw-r--r--release/scripts/scripttemplate_gamelogic.py5
9 files changed, 251 insertions, 375 deletions
diff --git a/release/freedesktop/blender.desktop b/release/freedesktop/blender.desktop
new file mode 100644
index 00000000000..39e0e3afe8e
--- /dev/null
+++ b/release/freedesktop/blender.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Encoding=UTF-8
+Name=Blender
+Comment=3D modeling, animation, rendering and post-production
+Exec=blender
+Icon=blender.png
+Terminal=false
+Type=Application
+Categories=Graphics;3DGraphics;
+MimeType=application/x-blender;
diff --git a/release/scripts/bpymodules/paths_svg2obj.py b/release/scripts/bpymodules/paths_svg2obj.py
index de40bea3191..d51fe74190d 100644
--- a/release/scripts/bpymodules/paths_svg2obj.py
+++ b/release/scripts/bpymodules/paths_svg2obj.py
@@ -1,7 +1,7 @@
# -*- coding: latin-1 -*-
"""
-SVG 2 OBJ translater, 0.5.9h
-Copyright (c) jm soler juillet/novembre 2004-april 2007,
+SVG 2 OBJ translater, 0.5.9n
+Copyright (c) jm soler juillet/novembre 2004-february 2009,
# ---------------------------------------------------------------
released under GNU Licence
for the Blender 2.42 Python Scripts Bundle.
@@ -20,7 +20,6 @@ en même temps que ce programme ; si ce n'est pas le cas, écrivez à la
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
MA 02111-1307, États-Unis.
-
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
@@ -35,7 +34,7 @@ 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 St, Fifth Floor, Boston, MA 02110-1301 USA
# ---------------------------------------------------------------
-
+#
#---------------------------------------------------------------------------
# Page officielle :
# http://jmsoler.free.fr/didacticiel/blender/tutor/cpl_import_svg.htm
@@ -253,15 +252,27 @@ Changelog:
0.5.9h : - 2007/5/2
- script was updated with the modifs by cambo
- - removed all debug statements
+ - removed all debug statements
- correction of a zero division error in the calc_arc function.
+ 0.5.9f: - 2007/15/7
+ - Correction de plusieurs bugs sur l'attributions des couleurs et le nommage
+ des courbes
+
+ 0.5.9i : - ??/??/??
+ - Patch externe réalisé sur blender.org project.
+
+ 0.5.9j : - 08/11/2008
+ 0.5.9k : - 14/01/2009
+ 0.5.9l : - 31/01/2009
+ 0.5.9n : - 01/02/2009
+
==================================================================================
=================================================================================="""
SHARP_IMPORT=0
SCALE=1
scale_=1
-DEBUG = 0#print
+DEBUG = 0
DEVELOPPEMENT=0
TESTCOLOR=0
@@ -533,7 +544,7 @@ def createCURVES(curves, name):
scene.objects.selected = []
if not SEPARATE_CURVES:
- c = Curve.New()
+ c = Curve.New()
c.setResolu(24)
MATNAME=[]
@@ -709,7 +720,6 @@ def circle(prp):
else : cx =float(prp['cx'])
if 'cy' not in prp: cy=0.0
else : cy =float(prp['cy'])
- #print prp.keys()
r = float(prp['r'])
D=['M',str(cx),str(cy+r),
'C',str(cx-r), str(cy+r*0.552),str(cx-0.552*r),str(cy+r), str(cx),str(cy+r),
@@ -852,7 +862,7 @@ def calc_arc (cpx,cpy, rx, ry, ang, fa , fs , x, y) :
#--------------------
# 0.3.9
#--------------------
-def curve_to_a(c,D,n0,CP): #A,a
+def curve_to_a(curves, c,D,n0,CP): #A,a
global SCALE
l=[float(D[c[1]+1]),float(D[c[1]+2]),float(D[c[1]+3]),
int(D[c[1]+4]),int(D[c[1]+5]),float(D[c[1]+6]),float(D[c[1]+7])]
@@ -866,8 +876,7 @@ def curve_to_a(c,D,n0,CP): #A,a
POINTS= calc_arc (CP[0],CP[1],
l[0], l[1], l[2]*(PI / 180.0),
l[3], l[4],
- l[5], l[6] )
- #if DEBUG == 1 : print POINTS
+ l[5], l[6] )
for p in POINTS :
B=Bez()
B.co=[ p[2][0],p[2][1], p[0][0],p[0][1], p[1][0],p[1][1]]
@@ -881,16 +890,23 @@ def curve_to_a(c,D,n0,CP): #A,a
BP.co[2]=BP.co[0]
BP.co[3]=BP.co[1]
CP=[l[5], l[6]]
+ #---------- 059m------------
+ if len(D)>c[1]+7 and D[c[1]+8] not in TAGcourbe :
+ c[1]+=7
+ curves,n0,CP=curve_to_a(curves, c, D, n0,CP)
+ #---------- 059m------------
return curves,n0,CP
-def move_to(c, D, n0,CP, proprietes):
+def move_to(curves, c, D, n0,CP, proprietes):
global DEBUG,TAGcourbe, LAST_ID
global USE_COLORS
l=[float(D[c[1]+1]),float(D[c[1]+2])]
+
if c[0]=='m':
l=[l[0]+CP[0],
l[1] + CP[1]]
+
if n0 in curves.ITEM:
n0+=1
CP=[l[0],l[1]]
@@ -917,14 +933,12 @@ def move_to(c, D, n0,CP, proprietes):
B.co=[CP[0],CP[1],CP[0],CP[1],CP[0],CP[1]]
B.ha=['L','C']
B.tag=c[0]
- curves.ITEM[n0].beziers_knot.append(B)
- #if DEBUG==1: print curves.ITEM[n0], CP
+ curves.ITEM[n0].beziers_knot.append(B)
return curves,n0,CP
-def close_z(c,D,n0,CP): #Z,z
+def close_z(curves, c,D,n0,CP): #Z,z
curves.ITEM[n0].flagUV[0]=1
if len(curves.ITEM[n0].beziers_knot)>1:
- #print len(curves.ITEM[n0].beziers_knot)
BP=curves.ITEM[n0].beziers_knot[-1]
BP0=curves.ITEM[n0].beziers_knot[0]
if BP.tag in ['c','C','s','S',]:
@@ -936,7 +950,7 @@ def close_z(c,D,n0,CP): #Z,z
n0-=1
return curves,n0,CP
-def curve_to_q(c,D,n0,CP): #Q,q
+def curve_to_q(curves, c,D,n0,CP): #Q,q
l=[float(D[c[1]+1]),float(D[c[1]+2]),float(D[c[1]+3]),float(D[c[1]+4])]
if c[0]=='q':
l=[l[0]+CP[0], l[1]+CP[1], l[2]+CP[0], l[3]+CP[1]]
@@ -948,15 +962,14 @@ def curve_to_q(c,D,n0,CP): #Q,q
BP.co[2]=BP.co[0]
BP.co[3]=BP.co[1]
curves.ITEM[n0].beziers_knot.append(B)
- #if DEBUG==1: print B.co,BP.co
CP=[l[2],l[3]]
#if DEBUG==1: pass
if len(D)>c[1]+5 and D[c[1]+5] not in TAGcourbe :
c[1]+=4
- curve_to_q(c, D, n0,CP)
+ curves,n0,CP=curve_to_q(curves, c, D, n0,CP)
return curves,n0,CP
-def curve_to_t(c,D,n0,CP): #T,t
+def curve_to_t(curves, c,D,n0,CP): #T,t
l=[float(D[c[1]+1]),float(D[c[1]+2])]
if c[0]=='t':
l=[l[0]+CP[0], l[1]+CP[1]]
@@ -970,11 +983,10 @@ def curve_to_t(c,D,n0,CP): #T,t
BP.co[2]=l0[2]
BP.co[3]=l0[3]
curves.ITEM[n0].beziers_knot.append(B)
- #if DEBUG==1: print B.co,BP.co
CP=[l[0],l[1]]
if len(D)>c[1]+3 and D[c[1]+3] not in TAGcourbe :
c[1]+=4
- curve_to_t(c, D, n0,CP)
+ curves,n0,CP=curve_to_t(curves, c, D, n0,CP)
return curves,n0,CP
#--------------------
@@ -985,7 +997,7 @@ def build_SYMETRIC(l):
Y=l[3]-(l[1]-l[3])
return X,Y
-def curve_to_s(c,D,n0,CP): #S,s
+def curve_to_s(curves, c,D,n0,CP): #S,s
l=[float(D[c[1]+1]),
float(D[c[1]+2]),
float(D[c[1]+3]),
@@ -1003,17 +1015,16 @@ def curve_to_s(c,D,n0,CP): #S,s
#--------------------
BP.co[2],BP.co[3]=build_SYMETRIC([BP.co[4],BP.co[5],BP.co[0],BP.co[1]])
curves.ITEM[n0].beziers_knot.append(B)
- #if DEBUG==1: print B.co,BP.co
#--------------------
# 0.4.3
#--------------------
CP=[l[2],l[3]]
if len(D)>c[1]+5 and D[c[1]+5] not in TAGcourbe :
c[1]+=4
- curve_to_c(c, D, n0,CP)
+ curves,n0,CP=curve_to_c(curves, c, D, n0,CP)
return curves,n0,CP
-def curve_to_c(c, D, n0,CP): #c,C
+def curve_to_c(curves, c, D, n0,CP): #c,C
l=[float(D[c[1]+1]),float(D[c[1]+2]),float(D[c[1]+3]),
float(D[c[1]+4]),float(D[c[1]+5]),float(D[c[1]+6])]
if c[0]=='c':
@@ -1030,6 +1041,8 @@ def curve_to_c(c, D, n0,CP): #c,C
l[5],
l[2],
l[3]] #plus toucher au 2-3
+
+
B.ha=['C','C']
B.tag=c[0]
BP=curves.ITEM[n0].beziers_knot[-1]
@@ -1037,32 +1050,38 @@ def curve_to_c(c, D, n0,CP): #c,C
BP.co[3]=l[1]
BP.ha[1]='C'
curves.ITEM[n0].beziers_knot.append(B)
- #if DEBUG==1: print B.co,BP.co
CP=[l[4],l[5]]
if len(D)>c[1]+7 and D[c[1]+7] not in TAGcourbe :
- c[1]+=6
- curve_to_c(c, D, n0,CP)
+ c[1]+=6
+ curves,n0,CP=curve_to_c(curves, c, D, n0,CP)
return curves,n0,CP
-def draw_line_l(c, D, n0,CP): #L,l
- l=[float(D[c[1]+1]),float(D[c[1]+2])]
+def draw_line_l(curves, c, D, n0,CP): #L,l
+
+ l=[float(D[c[1]+1]),float(D[c[1]+2])]
if c[0]=='l':
l=[l[0]+CP[0],
- l[1]+CP[1]]
+ l[1]+CP[1]]
B=Bez()
- B.co=[l[0],l[1],l[0],l[1],l[0],l[1]]
+ B.co=[l[0],l[1],
+ l[0],l[1],
+ l[0],l[1]]
+
B.ha=['L','L']
B.tag=c[0]
BP=curves.ITEM[n0].beziers_knot[-1]
BP.ha[1]='L'
+
curves.ITEM[n0].beziers_knot.append(B)
- CP=[B.co[0],B.co[1]]
+ CP=[B.co[4],B.co[5]]
+
if len(D)>c[1]+3 and D[c[1]+3] not in TAGcourbe :
c[1]+=2
- draw_line_l(c, D, n0,CP) #L
+ curves,n0,CP=draw_line_l(curves, c, D, n0,CP) #L
+
return curves,n0,CP
-def draw_line_h(c,D,n0,CP): #H,h
+def draw_line_h(curves, c,D,n0,CP): #H,h
if c[0]=='h':
l=[float(D[c[1]+1])+float(CP[0]),CP[1]]
else:
@@ -1077,7 +1096,7 @@ def draw_line_h(c,D,n0,CP): #H,h
CP=[l[0],l[1]]
return curves,n0,CP
-def draw_line_v(c,D,n0,CP): #V, v
+def draw_line_v(curves, c,D,n0,CP): #V, v
if c[0]=='v':
l=[CP[0], float(D[c[1]+1])+CP[1]]
else:
@@ -1121,17 +1140,31 @@ TAGtransform=['M','L','C','S','H','V','T','Q']
tagTRANSFORM=0
def wash_DATA(ndata):
- if ndata:
- #if DEBUG==1: print ndata
+ if ndata:
ndata = ndata.strip()
+
if ndata[0]==',':ndata=ndata[1:]
if ndata[-1]==',':ndata=ndata[:-1]
+
#--------------------
# 0.4.0 : 'e'
#--------------------
- i = ndata.find('-')
- if i != -1 and ndata[i-1] not in ' ,e':
- ndata=ndata.replace('-',',-')
+ ni=0
+ i = ndata.find('-',ni)
+ if i != -1:
+ while i>-1 :
+ i = ndata.find('-',ni)
+ # 059l ------
+ if i>0 :
+ if ndata[i-1] not in [' ',',','e']:
+ ndata=ndata[:i]+','+ndata[i:]
+ ni=i+2
+ else:
+ ni=i+1
+ elif i>-1:
+ ni=1
+ # 059l ------
+
ndata=ndata.replace(',,',',')
ndata=ndata.replace(' ',',')
ndata=ndata.split(',')
@@ -1153,7 +1186,7 @@ def list_DATA(DATA):
# borner les differents segments qui devront etre
# traites
# pour cela construire une liste avec chaque
- # la position de chaqe emplacement tag de type
+ # position de chaque emplacement tag de type
# commande path...
# ----------------------------------------
tagplace=[]
@@ -1169,8 +1202,10 @@ def list_DATA(DATA):
# d'apparition des tags
#------------------------------------------
tagplace.sort()
-
+
tpn=range(len(tagplace))
+
+
#--------------------
# 0.3.5 :: short data, only one tag
#--------------------
@@ -1179,14 +1214,18 @@ def list_DATA(DATA):
for t in tpn[:-1]:
DATA2.append(DATA[tagplace[t]:tagplace[t]+1])
ndata=DATA[tagplace[t]+1:tagplace[t+1]]
+
if DATA2[-1] not in ['z','Z'] :
ndata=wash_DATA(ndata)
DATA2.extend(ndata)
+
DATA2.append(DATA[tagplace[t+1]:tagplace[t+1]+1])
+
if DATA2[-1] not in ['z','Z'] and len(DATA)-1>=tagplace[t+1]+1:
ndata=DATA[tagplace[t+1]+1:]
ndata=wash_DATA(ndata)
DATA2.extend(ndata) #059a
+
else:
#--------------------
# 0.3.5 : short data,only one tag
@@ -1276,15 +1315,13 @@ def control_CONTAINT(txt):
nt0=txt[t0:t1+1]
t2=nt0[nt0.find('(')+1:-1]
val=nt0[:nt0.find('(')]
+
while t2.find(' ')!=-1:
t2=t2.replace(' ',' ')
- t2=t2.replace(' ',',')
+ while t2.find(', ')!=-1: #059l
+ t2=t2.replace(', ',',') #059l
- """
- t2=t2.split(',')
- for index, t in enumerate(t2):
- t2[index]=float(t)
- """
+ t2=t2.replace(' ',',')
t2=[float(t) for t in t2.split(',')]
if val=='rotate' :
@@ -1314,12 +1351,24 @@ def curve_FILL(Courbe,proprietes):
i= i+6
Courbe[n].color=[int(pr[i:i+2],16),int(pr[i+2:i+4],16),int(pr[i+4:i+6],16)]
Courbe[n].mat=1
- elif ';fill-opacity' in pr:
- i= pr.find('fill:')+5
- i2= pr.find(';',i)
- COLORNAME= pr[i:i2]
- Courbe[n].color=SVGCOLORNAMELIST[COLORNAME]
- Courbe[n].mat=1
+ elif ';fill-opacity' in pr:
+ if pr.find('fill:url')==-1:
+ i= pr.find('fill:')+5
+ i2= pr.find(';',i)
+ COLORNAME= pr[i:i2]
+ Courbe[n].color=SVGCOLORNAMELIST[COLORNAME]
+ Courbe[n].mat=1
+ elif 'color:' in pr:
+ i= pr.find('color:')+6
+ i2= pr.find(';',i)
+ COLORNAME= pr[i:i2]
+ Courbe[n].color=SVGCOLORNAMELIST[COLORNAME]
+ Courbe[n].mat=1
+ else :
+ COLORNAME= 'white'
+ Courbe[n].color=SVGCOLORNAMELIST[COLORNAME]
+ Courbe[n].mat=1
+
#----------------------------------------------
# 0.4.1 : apply transform stack
#----------------------------------------------
@@ -1367,9 +1416,8 @@ def filter(d):
def get_BOUNDBOX(BOUNDINGBOX,SVG):
if 'viewbox' not in SVG:
h=float(filter(SVG['height']))
- #if DEBUG==1 : print 'h : ',h
+
w=float(filter(SVG['width']))
- #if DEBUG==1 : print 'w :',w
BOUNDINGBOX['rec']=[0.0,0.0,w,h]
r=BOUNDINGBOX['rec']
BOUNDINGBOX['coef']=w/h
@@ -1444,7 +1492,6 @@ def build_HIERARCHY(t):
b=balisetype.index(t[t0+1])
if t[t0+2]=='-':
b=balisetype.index(t[t0+1])+1
- #print t[t0:t1]
balise=BALISES[b]
if b==2:
parent=STACK.pop(-1)
@@ -1465,12 +1512,8 @@ def build_HIERARCHY(t):
if balise=='E' or balise=='O':
proprietes=collect_ATTRIBUTS(t[t0:t1+ouvrante])
- #print proprietes
if 'id' in proprietes:
LAST_ID=proprietes['id']
- #print LAST_ID
-
-
if balise=='O' and 'transform' in proprietes:
STACK.append(proprietes['transform'])
@@ -1489,20 +1532,20 @@ def build_HIERARCHY(t):
# 0.5.8, to remove exec
#--------------------
D=OTHERSSHAPES[proprietes['TYPE']](proprietes)
-
+ CP=[0.0,0.0]
if len(D)>0:
cursor=0
proprietes['n']=[]
for cell in D:
- #if DEBUG==2 : print 'cell : ',cell ,' --'
+
if len(cell)>=1 and cell[0] in TAGcourbe:
#--------------------
# 0.5.8, to remove exec
#--------------------
if cell[0] in ['m','M']:
- curves,n0,CP=Actions[cell]([cell,cursor], D, n0,CP,proprietes)
+ curves,n0,CP=Actions[cell](curves, [cell,cursor], D, n0,CP,proprietes)
else:
- curves,n0,CP=Actions[cell]([cell,cursor], D, n0,CP)
+ curves,n0,CP=Actions[cell](curves, [cell,cursor], D, n0,CP)
cursor+=1
if TRANSFORM>0 or 'transform' in proprietes :
@@ -1513,7 +1556,6 @@ def build_HIERARCHY(t):
elif proprietes['TYPE'] == 'svg':
- #print 'proprietes.keys()',proprietes.keys()
BOUNDINGBOX = get_BOUNDBOX(BOUNDINGBOX,proprietes)
else:
#--------------------
diff --git a/release/scripts/export_fbx.py b/release/scripts/export_fbx.py
index 6f964118964..730776bf1b8 100644
--- a/release/scripts/export_fbx.py
+++ b/release/scripts/export_fbx.py
@@ -1446,13 +1446,13 @@ def write(filename, batch_objects = None, \
for f in me.faces:
for col in f.col:
if i==-1:
- file.write('%i,%i,%i,255' % (col[0], col[1], col[2]))
+ file.write('%.4f,%.4f,%.4f,1' % (col[0]/255.0, col[1]/255.0, col[2]/255.0))
i=0
else:
if i==7:
file.write('\n\t\t\t\t')
i=0
- file.write(',%i,%i,%i,255' % (col[0], col[1], col[2]))
+ file.write(',%.4f,%.4f,%.4f,1' % (col[0]/255.0, col[1]/255.0, col[2]/255.0))
i+=1
ii+=1 # One more Color
diff --git a/release/scripts/export_obj.py b/release/scripts/export_obj.py
index 9feb02638c3..28e1443e953 100644
--- a/release/scripts/export_obj.py
+++ b/release/scripts/export_obj.py
@@ -120,7 +120,7 @@ def write_mtl(filename):
if img: # We have an image on the face!
file.write('map_Kd %s\n' % img.filename.split('\\')[-1].split('/')[-1]) # Diffuse mapping image
- elif not mat: # No face image. if we havea material search for MTex image.
+ elif mat: # No face image. if we havea material search for MTex image.
for mtex in mat.getTextures():
if mtex and mtex.tex.type == Blender.Texture.Types.IMAGE:
try:
diff --git a/release/scripts/import_dxf.py b/release/scripts/import_dxf.py
index 6a1981bb262..c3203891c60 100644
--- a/release/scripts/import_dxf.py
+++ b/release/scripts/import_dxf.py
@@ -7,7 +7,7 @@ Group: 'Import'
Tooltip: 'Import for DXF geometry data (Drawing eXchange Format).'
"""
__author__ = 'Kitsu(Ed Blake) & migius(Remigiusz Fiedler)'
-__version__ = '1.12 - 2008.11.16 by migius'
+__version__ = '1.12 - 2009.03.14 by migius'
__url__ = ["http://blenderartists.org/forum/showthread.php?t=84319",
"http://wiki.blender.org/index.php/Scripts/Manual/Import/DXF-3D"]
__email__ = ["migius(at)4d-vectors.de","Kitsune_e(at)yahoo.com"]
@@ -15,7 +15,7 @@ __bpydoc__ = """\
This script imports objects from DXF (2d/3d) into Blender.
This script imports 2d and 3d geometery from DXF files.
-Supported DXF format versions: from (r2.5) r12 up to 2008.
+Supported DXF format versions: from (r2.5) r12 up to r2008.
Enhanced features are:
- configurable object filtering and geometry manipulation,
- configurable material pre-processing,
@@ -32,7 +32,7 @@ MINSERT (=array of blocks),
CIRCLE,
ARC,
3DFACE,
-2d-POLYLINE (=plane, incl. arc, variable-width, curve, spline),
+2d-POLYLINE (=in plane, incl. arc, variable-width, curve, spline),
3d-POLYLINE (=non-plane),
3d-POLYMESH,
3d-POLYFACE,
@@ -57,7 +57,7 @@ Supported layout modes:
"model space" is default,
"paper space" as option (= "layout views")
-Supported scene definition objescts produced with AVE_RENDER:
+Supported scene definition objects produced with AVE_RENDER:
scene: selection of lights assigned to the camera,
lights: DIRECT, OVERHEAD, SH_SPOT,
(wip v1.13 import of AVE_RENDER material definitions)
@@ -88,7 +88,7 @@ in creating new objects in scene database - probably a database management probl
"""
History:
- v1.0 - 2007/2008 by migius
+ v1.0 - 2007/2008/2009 by migius
planned tasks:
-- (to see more, search for "--todo--" in script code)
-- command-line-mode/batch-mode
@@ -111,6 +111,11 @@ History:
-- support ortho mode for VIEWs and VPORTs as cameras
+ v1.12 - 2009.03.14 by migius
+ d3 removed all set()functions (problem with osx/python<2.4 reported by Blinkozo)
+ d3 code-cleaning
+ v1.12 - 2009.01.14 by migius
+ d2 temp patch for noname BLOCKS (*X,*U,*D)
v1.12 - 2008.11.16 by migius
d1 remove try_finally: cause not supported in python <2.5
d1 add Bezier curves bevel radius support (default 1.0)
@@ -309,9 +314,17 @@ from dxfReader import readDXF
#from dxfReader import get_name, get_layer
from dxfReader import Object as dxfObject
from dxfColorMap import color_map
-
from math import *
+# osx-patch by Blinkozo
+#todo: avoid additional modules, prefer Blender-build-in test routines
+#import platform
+#if platform.python_version() < '2.4':
+# from sets import Set as set
+#from sys import version_info
+#ver = '%s.%s' % version_info[0:2]
+# end osx-patch
+
try:
import os
if os.name != 'mac':
@@ -950,7 +963,7 @@ class Point: #-----------------------------------------------------------------
if thic < settings.var['dist_min']: thic = settings.var['dist_min']
if points_as in [1,3,4,5]:
- if True: # points_as in [1,5]: # as 'empty'
+ if points_as in [1,5]: # as 'empty'
c = 'Empty'
elif points_as == 3: # as 'thin sphere'
res = settings.var['thin_res']
@@ -1276,66 +1289,6 @@ class Polyline: #--------------------------------------------------------------
pline = Curve.New(obname) # create new curve data
#pline.setResolu(24) #--todo-----
- if False: #old self.spline: # NURBSplines-----OK-----
- #print 'deb:polyline2dCurve.draw self.spline!' #---------------
- weight1 = 0.5
- weight2 = 1.0
- if self.curvQuadrati:
- # Bezier-curve form simulated in NURBS-curve
- # generate middlepoints except start/end-segments ---
- #print 'deb:polyline2dCurve.draw extraQBspline!' #---------------
- temp_points = []
- point = d_points[0].loc
- point.append(weight1)
- temp_points.append(point)
- for i in xrange(1,len(d_points)-2):
- point1 = d_points[i].loc
- point2 = d_points[i+1].loc
- mpoint = list((Mathutils.Vector(point1) + Mathutils.Vector(point2)) * 0.5)
- mpoint.append(weight2)
- point1.append(weight1)
- temp_points.append(point1)
- temp_points.append(mpoint)
- point2.append(weight1)
- temp_points.append(point2)
- point = d_points[-1].loc
- point.append(weight1)
- temp_points.append(point)
- d_points = temp_points
- else:
- temp_points = []
- for d in d_points:
- d = d.loc
- d.append(weight1)
- temp_points.append(d)
- d_points = temp_points
-
- if not self.closed:
- # generate extended startpoint and endpoint------
- point1 = Mathutils.Vector(d_points[0][:3])
- point2 = Mathutils.Vector(d_points[1][:3])
- startpoint = list(point1 - point2 + point1)
- startpoint.append(weight1)
- point1 = Mathutils.Vector(d_points[-1][:3])
- point2 = Mathutils.Vector(d_points[-2][:3])
- endpoint = list(point1 - point2 + point1)
- endpoint.append(weight1)
- temp_points = []
- temp_points.append(startpoint)
- temp_points.extend(d_points)
- d_points = temp_points
- d_points.append(endpoint)
-
- point = d_points[0]
- curve = pline.appendNurb(point)
- curve.setType(4) #NURBS curve
- for point in d_points[1:]:
- curve.append(point)
- if self.closed:
- curve.flagU = 1 # Set curve cyclic=close
- else:
- curve.flagU = 0 # Set curve not cyclic=open
-
if self.spline: # NURBSplines-----OK-----
#print 'deb:polyline2dCurve.draw self.spline!' #---------------
nurbs_points = []
@@ -1358,21 +1311,6 @@ class Polyline: #--------------------------------------------------------------
except AttributeError: pass
#print 'deb: dir(curve):', dir(curve) #----------------
- elif False: #orig self.curved: #--Bezier-curves---OK-------
- #print 'deb:polyline2dCurve.draw self.curved!' #---------------
- curve = pline.appendNurb(BezTriple.New(d_points[0]))
- for p in d_points[1:]:
- curve.append(BezTriple.New(p))
- for point in curve:
- point.handleTypes = [AUTO, AUTO]
- point.radius = 1.0
- if self.closed:
- curve.flagU = 1 # Set curve cyclic=close
- else:
- curve.flagU = 0 # Set curve not cyclic=open
- curve[0].handleTypes = [FREE, ALIGN] #remi--todo-----
- curve[-1].handleTypes = [ALIGN, FREE] #remi--todo-----
-
elif self.curved: #--SPLINE as Bezier-curves---wip------
#print 'deb:polyline2dCurve.draw self.curved!' #---------------
begtangent, endtangent = None, None
@@ -1424,68 +1362,48 @@ class Polyline: #--------------------------------------------------------------
for i in xrange(len(d_points)):
point1 = d_points[i]
#point2 = d_points[i+1]
- if False: #-----outdated!- standard calculation ----------------------------------
- if point1.bulge and (i < len(d_points)-2 or self.closed):
- verts, center = calcBulge(point1, point2, arc_res, triples=False)
- if i == 0: curve = pline.appendNurb(BezTriple.New(verts[0]))
- else: curve.append(BezTriple.New(verts[0]))
- curve[-1].handleTypes = [VECT, VECT] #--todo--calculation of bezier-tangents
- curve[-1].radius = 1.0
- for p in verts[1:]:
- curve.append(BezTriple.New(p))
- curve[-1].handleTypes = [AUTO, AUTO]
- curve[-1].radius = 1.0
- else:
- if i == 0: curve = pline.appendNurb(BezTriple.New(point1.loc))
- else: curve.append(BezTriple.New(point1.loc))
- curve[-1].handleTypes = [VECT, VECT] #--todo--calculation of bezier-tangents
- curve[-1].radius = 1.0
+ #----- optimised Bezier-Handles calculation --------------------------------
+ #print 'deb:drawPlineCurve: i:', i #---------
+ if point1.bulge and not (i == len(d_points)-1 and point1.bulge and not self.closed):
+ if i == len(d_points)-1: point2 = d_points[0]
+ else: point2 = d_points[i+1]
- elif True: #----- optimised Bezier-Handles calculation --------------------------------
- #print 'deb:drawPlineCurve: i:', i #---------
- if point1.bulge and not (i == len(d_points)-1 and point1.bulge and not self.closed):
- if i == len(d_points)-1: point2 = d_points[0]
- else: point2 = d_points[i+1]
+ # calculate additional points for bulge
+ VectorTriples = calcBulge(point1, point2, arc_res, triples=True)
- # calculate additional points for bulge
- VectorTriples = calcBulge(point1, point2, arc_res, triples=True)
+ if prevHandleType == FREE:
+ #print 'deb:drawPlineCurve: VectorTriples[0]:', VectorTriples[0] #---------
+ VectorTriples[0][:3] = prevHandleVect
+ #print 'deb:drawPlineCurve: VectorTriples[0]:', VectorTriples[0] #---------
- if prevHandleType == FREE:
- #print 'deb:drawPlineCurve: VectorTriples[0]:', VectorTriples[0] #---------
- VectorTriples[0][:3] = prevHandleVect
- #print 'deb:drawPlineCurve: VectorTriples[0]:', VectorTriples[0] #---------
+ if i == 0: curve = pline.appendNurb(BezTriple.New(VectorTriples[0]))
+ else: curve.append(BezTriple.New(VectorTriples[0]))
+ curve[-1].handleTypes = [prevHandleType, FREE]
+ curve[-1].radius = 1.0
- if i == 0: curve = pline.appendNurb(BezTriple.New(VectorTriples[0]))
- else: curve.append(BezTriple.New(VectorTriples[0]))
- curve[-1].handleTypes = [prevHandleType, FREE]
+ for p in VectorTriples[1:-1]:
+ curve.append(BezTriple.New(p))
+ curve[-1].handleTypes = [FREE, FREE]
curve[-1].radius = 1.0
- for p in VectorTriples[1:-1]:
- curve.append(BezTriple.New(p))
- curve[-1].handleTypes = [FREE, FREE]
- curve[-1].radius = 1.0
-
- prevHandleVect = VectorTriples[-1][:3]
- prevHandleType = FREE
- #print 'deb:drawPlineCurve: prevHandleVect:', prevHandleVect #---------
+ prevHandleVect = VectorTriples[-1][:3]
+ prevHandleType = FREE
+ #print 'deb:drawPlineCurve: prevHandleVect:', prevHandleVect #---------
+ else:
+ #print 'deb:drawPlineCurve: else' #----------
+ if prevHandleType == FREE:
+ VectorTriples = prevHandleVect + list(point1) + list(point1)
+ #print 'deb:drawPlineCurve: VectorTriples:', VectorTriples #---------
+ curve.append(BezTriple.New(VectorTriples))
+ curve[-1].handleTypes = [FREE, VECT]
+ prevHandleType = VECT
+ curve[-1].radius = 1.0
else:
- #print 'deb:drawPlineCurve: else' #----------
- if prevHandleType == FREE:
- VectorTriples = prevHandleVect + list(point1) + list(point1)
- #print 'deb:drawPlineCurve: VectorTriples:', VectorTriples #---------
- curve.append(BezTriple.New(VectorTriples))
- curve[-1].handleTypes = [FREE, VECT]
- prevHandleType = VECT
- curve[-1].radius = 1.0
- else:
- if i == 0: curve = pline.appendNurb(BezTriple.New(point1.loc))
- else: curve.append(BezTriple.New(point1.loc))
- curve[-1].handleTypes = [VECT, VECT]
- curve[-1].radius = 1.0
-
-
-
+ if i == 0: curve = pline.appendNurb(BezTriple.New(point1.loc))
+ else: curve.append(BezTriple.New(point1.loc))
+ curve[-1].handleTypes = [VECT, VECT]
+ curve[-1].radius = 1.0
#print 'deb:drawPlineCurve: curve[-1].vec[0]', curve[-1].vec[0] #----------
if self.closed:
@@ -1584,23 +1502,6 @@ class Polyline: #--------------------------------------------------------------
d_points = self.doubles_out(settings, d_points)
#print 'deb:drawPolyCurve d_pointsList =after DV-outsorting=====:\n ', d_points #------------------------
- """# routine to sort out of "double.vertices" ------------------------------------
- minimal_dist = settings.var['dist_min'] * 0.1
- temp_points = []
- for i in xrange(len(d_points)-1):
- point = d_points[i]
- point2 = d_points[i+1]
- #print 'deb:double.vertex p1,p2', point, point2 #------------------------
- delta = Mathutils.Vector(point2.loc) - Mathutils.Vector(point.loc)
- if delta.length > minimal_dist:
- temp_points.append(point)
- #else: print 'deb:drawPoly2d double.vertex sort out!' #------------------------
- temp_points.append(d_points[-1]) #------ incl. last vertex -------------
- #if self.closed: temp_points.append(d_points[1]) #------ loop start vertex -------------
- d_points = temp_points #-----vertex.list without "double.vertices"
- #print 'deb:drawPoly2d d_pointsList =after DV-outsorting=====:\n ', d_points #------------------------
- """
-
#print 'deb:drawPoly2d len of d_pointsList ====== ', len(d_points) #------------------------
if len(d_points) < 2: #if too few vertex, then return
#print 'deb:drawPoly2d corrupted Vertices' #---------
@@ -1796,29 +1697,6 @@ class Polyline: #--------------------------------------------------------------
# clean corner intersection
pointsLc.append(cornerpointL)
pointsRc.append(cornerpointR)
- elif False: # the standard no-intersection
- # --todo-- not optimal, because produces X-face
- pointsLc.extend((pointsLe[i],pointsLs[i+1]))
- pointsRc.extend((pointsRe[i],pointsRs[i+1]))
- elif False: # --todo-- the optimised non-intersection
- if (cornerpointL - vecL1).length < (cornerpointR - vecR1).length:
- left_angle = True
- else:
- left_angle = False
- limit_dist = settings.var['dist_min']
- if left_angle: # if left turning angle
- #print 'deb:drawPoly2d it is left turning angle' #-------------
- # to avoid triangelface/doubleVertex
- delta1 = (cornerpointL - vecL1).normalize() * limit_dist
- delta4 = (cornerpointL - vecL4).normalize() * limit_dist
- pointsLc.extend((cornerpointL - delta1, cornerpointL - delta4))
- pointsRc.extend((pointsRe[i],pointsRs[i+1]))
- else: # if right turning angle
- #print 'deb:drawPoly2d right turning angle' #-------------
- delta1 = (cornerpointR - vecR1).normalize() * limit_dist
- delta4 = (cornerpointR - vecR4).normalize() * limit_dist
- pointsRc.extend((cornerpointR - delta1, cornerpointR - delta4))
- pointsLc.extend((pointsLe[i],pointsLs[i+1]))
else:
pointsLc.extend((pointsLe[i],points[i+1],pointsLs[i+1]))
pointsRc.extend((pointsRe[i],points[i+1],pointsRs[i+1]))
@@ -1855,14 +1733,10 @@ class Polyline: #--------------------------------------------------------------
vecR3, vecR4 = pointsRs[i+1], pointsRe[i+1]
if bulg_points[i] != None:
#compute left- and right-cornerpoints
- if True:
- cornerpointL = Mathutils.LineIntersect(vecL1, vecL2, vecL3, vecL4)
- cornerpointR = Mathutils.LineIntersect(vecR1, vecR2, vecR3, vecR4)
- pointsLc.append(cornerpointL[0])
- pointsRc.append(cornerpointR[0])
- else:
- pointVec = Mathutils.Vector(point[i])
-
+ cornerpointL = Mathutils.LineIntersect(vecL1, vecL2, vecL3, vecL4)
+ cornerpointR = Mathutils.LineIntersect(vecR1, vecR2, vecR3, vecR4)
+ pointsLc.append(cornerpointL[0])
+ pointsRc.append(cornerpointR[0])
else: # IF non-bulg
pointsLc.extend((pointsLe[i],points[i+1],pointsLs[i+1]))
pointsRc.extend((pointsRe[i],points[i+1],pointsRs[i+1]))
@@ -1924,21 +1798,20 @@ class Polyline: #--------------------------------------------------------------
for v in f_right: vg_right.extend(v)
for v in f_top: vg_top.extend(v)
for v in f_bottom: vg_bottom.extend(v)
- me.addVertGroup('side.left') ; me.assignVertsToGroup('side.left', list(set(vg_left)), 1.0, replace)
- me.addVertGroup('side.right') ; me.assignVertsToGroup('side.right', list(set(vg_right)), 1.0, replace)
- me.addVertGroup('side.top') ; me.assignVertsToGroup('side.top', list(set(vg_top)), 1.0, replace)
- me.addVertGroup('side.bottom'); me.assignVertsToGroup('side.bottom',list(set(vg_bottom)), 1.0, replace)
+ me.addVertGroup('side.left') ; me.assignVertsToGroup('side.left', vg_left, 1.0, replace)
+ me.addVertGroup('side.right') ; me.assignVertsToGroup('side.right', vg_right, 1.0, replace)
+ me.addVertGroup('side.top') ; me.assignVertsToGroup('side.top', vg_top, 1.0, replace)
+ me.addVertGroup('side.bottom'); me.assignVertsToGroup('side.bottom',vg_bottom, 1.0, replace)
if not self.closed:
me.addVertGroup('side.start'); me.assignVertsToGroup('side.start', f_start[0], 1.0, replace)
me.addVertGroup('side.end') ; me.assignVertsToGroup('side.end', f_end[0], 1.0, replace)
if settings.var['meshSmooth_on']: # left and right side become smooth ----------------------
#if self.spline or self.curved:
- if True:
- smooth_len = len(f_left) + len(f_right)
- for i in xrange(smooth_len):
- me.faces[i].smooth = True
- #me.Modes(AUTOSMOOTH)
+ smooth_len = len(f_left) + len(f_right)
+ for i in xrange(smooth_len):
+ me.faces[i].smooth = True
+ #me.Modes(AUTOSMOOTH)
# 2.level:IF width, but no-thickness ---------------------
else:
@@ -1977,10 +1850,9 @@ class Polyline: #--------------------------------------------------------------
if settings.var['meshSmooth_on']: # left and right side become smooth ----------------------
#if self.spline or self.curved:
- if True:
- for i in xrange(len(faces)):
- me.faces[i].smooth = True
- #me.Modes(AUTOSMOOTH)
+ for i in xrange(len(faces)):
+ me.faces[i].smooth = True
+ #me.Modes(AUTOSMOOTH)
# 1.level:IF no-width and no-thickness ---------------------
else:
@@ -2684,38 +2556,17 @@ class Circle: #----------------------------------------------------------------
cyl_rad = 0.5 * settings.var['width_min']
if settings.var['lines_as'] == 5: # draw CIRCLE as curve -------------
- if True: # universal version
- arc_res = settings.var['curve_arc']
- #arc_res = 3
- start, end = 0.0, 360.0
- VectorTriples = calcArc(None, radius, start, end, arc_res, True)
- c = Curve.New(obname) # create new curve data
- curve = c.appendNurb(BezTriple.New(VectorTriples[0]))
- for p in VectorTriples[1:-1]:
- curve.append(BezTriple.New(p))
- for point in curve:
- point.handleTypes = [FREE, FREE]
- point.radius = 1.0
- else: # standard version
- c = Curve.New(obname) # create new curve data
- p1 = (0, -radius, 0)
- p2 = (radius, 0, 0)
- p3 = (0, radius, 0)
- p4 = (-radius, 0, 0)
-
- p1 = BezTriple.New(p1)
- p2 = BezTriple.New(p2)
- p3 = BezTriple.New(p3)
- p4 = BezTriple.New(p4)
-
- curve = c.appendNurb(p1)
- curve.append(p2)
- curve.append(p3)
- curve.append(p4)
- for point in curve:
- point.handleTypes = [AUTO, AUTO]
- point.radius = 1.0
-
+ arc_res = settings.var['curve_arc']
+ #arc_res = 3
+ start, end = 0.0, 360.0
+ VectorTriples = calcArc(None, radius, start, end, arc_res, True)
+ c = Curve.New(obname) # create new curve data
+ curve = c.appendNurb(BezTriple.New(VectorTriples[0]))
+ for p in VectorTriples[1:-1]:
+ curve.append(BezTriple.New(p))
+ for point in curve:
+ point.handleTypes = [FREE, FREE]
+ point.radius = 1.0
curve.flagU = 1 # 1 sets the curve cyclic=closed
if settings.var['fill_on']:
c.setFlag(6) # 2+4 set top and button caps
@@ -2737,24 +2588,6 @@ class Circle: #----------------------------------------------------------------
ob.SizeZ *= abs(thic)
return ob
- elif False: # create a new mesh_object with buildin_circle_primitive
- verts_num = settings.var['arc_res'] * sqrt(radius / settings.var['arc_rad'])
- if verts_num > 100: verts_num = 100 # Blender accepts only values [3:500]
- if verts_num < 4: verts_num = 4 # Blender accepts only values [3:500]
- if thic != 0:
- loc2 = thic * 0.5 #-----blenderAPI draw Cylinder with 2*thickness
- self.loc[2] += loc2 #---new location for the basis of cylinder
- #print 'deb:circleDraw:self.loc2:', self.loc #-----------------------
- c = Mesh.Primitives.Cylinder(int(verts_num), radius*2, abs(thic))
- else:
- c = Mesh.Primitives.Circle(int(verts_num), radius*2)
-
- #c.update()
- ob = SCENE.objects.new(c, obname) # create a new circle_mesh_object
- ob.loc = tuple(self.loc)
- transform(self.extrusion, 0, ob)
- return ob
-
else: # draw CIRCLE as mesh -----------------------------------------------
if M_OBJ: obname, me, ob = makeNewObject()
else:
@@ -2810,12 +2643,13 @@ class Circle: #----------------------------------------------------------------
replace = Blender.Mesh.AssignModes.REPLACE #or .AssignModes.ADD
vg_band, vg_top, vg_bottom = [], [], []
for v in f_band: vg_band.extend(v)
- me.addVertGroup('side.band') ; me.assignVertsToGroup('side.band', list(set(vg_band)), 1.0, replace)
+ me.addVertGroup('side.band') ; me.assignVertsToGroup('side.band', vg_band, 1.0, replace)
+
if settings.var['fill_on']:
for v in f_top: vg_top.extend(v)
for v in f_bottom: vg_bottom.extend(v)
- me.addVertGroup('side.top') ; me.assignVertsToGroup('side.top', list(set(vg_top)), 1.0, replace)
- me.addVertGroup('side.bottom'); me.assignVertsToGroup('side.bottom',list(set(vg_bottom)), 1.0, replace)
+ me.addVertGroup('side.top') ; me.assignVertsToGroup('side.top', vg_top, 1.0, replace)
+ me.addVertGroup('side.bottom'); me.assignVertsToGroup('side.bottom',vg_bottom, 1.0, replace)
else: # if thic == 0
if settings.var['fill_on']:
@@ -2992,10 +2826,10 @@ class Arc: #-----------------------------------------------------------------
for v in f_right: vg_right.extend(v)
for v in f_top: vg_top.extend(v)
for v in f_bottom: vg_bottom.extend(v)
- me.addVertGroup('side.left') ; me.assignVertsToGroup('side.left', list(set(vg_left)), 1.0, replace)
- me.addVertGroup('side.right') ; me.assignVertsToGroup('side.right', list(set(vg_right)), 1.0, replace)
- me.addVertGroup('side.top') ; me.assignVertsToGroup('side.top', list(set(vg_top)), 1.0, replace)
- me.addVertGroup('side.bottom'); me.assignVertsToGroup('side.bottom',list(set(vg_bottom)), 1.0, replace)
+ me.addVertGroup('side.left') ; me.assignVertsToGroup('side.left', vg_left, 1.0, replace)
+ me.addVertGroup('side.right') ; me.assignVertsToGroup('side.right', vg_right, 1.0, replace)
+ me.addVertGroup('side.top') ; me.assignVertsToGroup('side.top', vg_top, 1.0, replace)
+ me.addVertGroup('side.bottom'); me.assignVertsToGroup('side.bottom',vg_bottom, 1.0, replace)
me.addVertGroup('side.start'); me.assignVertsToGroup('side.start', f_start[0], 1.0, replace)
me.addVertGroup('side.end') ; me.assignVertsToGroup('side.end', f_end[0], 1.0, replace)
@@ -3247,8 +3081,6 @@ class Insert: #----------------------------------------------------------------
if a_data.key == 'SCENE': # define set of lights as blender group
scene_lights = 1
- elif False: # define set of lights as blender group
- scene_lights = 1
return
elif name == 'ave_global':
if settings.var['lights_on']: #if lights support activated
@@ -3409,35 +3241,12 @@ class Ellipse: #---------------------------------------------------------------
obname = obname[:MAX_NAMELENGTH]
center = self.loc
- if True:
- start = degrees(self.start_angle)
- end = degrees(self.end_angle)
- if abs(end - 360.0) < 0.00001: end = 360.0
- ellipse_closed = False
- if end - start == 360.0: ellipse_closed = True
+ start = degrees(self.start_angle)
+ end = degrees(self.end_angle)
+ if abs(end - 360.0) < 0.00001: end = 360.0
+ ellipse_closed = False
+ if end - start == 360.0: ellipse_closed = True
- else: # bug in AutoCAD_2002 dxf-exporter into r12 for ELLIPSE->POLYLINE_ARC
- #print 'deb:calcEllipse---------:\n start=%s\n end=%s' %(self.start_angle, self.end_angle) #---------
- if self.start_angle > pi+pi: self.start_angle %= pi+pi
- if self.end_angle > pi+pi: self.end_angle %= pi+pi
- if abs(self.end_angle - pi - pi) < 0.00001: self.end_angle = pi + pi
- ellipse_closed = False
- if abs(self.end_angle - self.start_angle) == pi + pi: ellipse_closed = True
- test = self.start_angle % pi
- if test < 0.001 or pi - test < 0.001: start = self.start_angle
- else:
- start = atan(tan(self.start_angle) * self.ratio)
- if start < 0.0: start += pi
- if self.start_angle > pi: start += pi
- test = self.end_angle % pi
- if test < 0.001 or pi - test < 0.001: end = self.end_angle
- else:
- end = atan(tan(self.end_angle) * self.ratio)
- if end < 0.0: end += pi
- if self.end_angle > pi: end += pi
- start = degrees(start)
- end = degrees(end)
-
# rotation = Angle between major and WORLDX
# doesnt work, couse produces always positive value: rotation = Mathutils.AngleBetweenVecs(major, WORLDX)
if self.major[0] == 0:
@@ -3512,8 +3321,6 @@ class Ellipse: #---------------------------------------------------------------
verts = calcArc(None, radius, start, end, arc_res, False)
#verts = [list(point) for point in verts]
- if False: #--todo--: if ellipse_closed:
- verts = verts[:-1] #list without last point/edge (cause closed curve)
len1 = len(verts)
#print 'deb:len1:', len1 #-----------------------
if width != 0:
@@ -3563,10 +3370,10 @@ class Ellipse: #---------------------------------------------------------------
for v in f_right: vg_right.extend(v)
for v in f_top: vg_top.extend(v)
for v in f_bottom: vg_bottom.extend(v)
- me.addVertGroup('side.left') ; me.assignVertsToGroup('side.left', list(set(vg_left)), 1.0, replace)
- me.addVertGroup('side.right') ; me.assignVertsToGroup('side.right', list(set(vg_right)), 1.0, replace)
- me.addVertGroup('side.top') ; me.assignVertsToGroup('side.top', list(set(vg_top)), 1.0, replace)
- me.addVertGroup('side.bottom'); me.assignVertsToGroup('side.bottom',list(set(vg_bottom)), 1.0, replace)
+ me.addVertGroup('side.left') ; me.assignVertsToGroup('side.left', vg_left, 1.0, replace)
+ me.addVertGroup('side.right') ; me.assignVertsToGroup('side.right', vg_right, 1.0, replace)
+ me.addVertGroup('side.top') ; me.assignVertsToGroup('side.top', vg_top, 1.0, replace)
+ me.addVertGroup('side.bottom'); me.assignVertsToGroup('side.bottom',vg_bottom, 1.0, replace)
me.addVertGroup('side.start'); me.assignVertsToGroup('side.start', f_start[0], 1.0, replace)
me.addVertGroup('side.end') ; me.assignVertsToGroup('side.end', f_end[0], 1.0, replace)
@@ -4378,8 +4185,9 @@ def analyzeDXF(dxfFile): #---------------------------------------
for item2 in drawing.entities.data:
if type(item2) != list and item2.type == 'insert':
- if not layersmap or (layersmap and not layersmap[item2.layer][1]): #if insert_layer is not frozen
- blocksmap[item2.name][0] = True # marked as world used BLOCK
+ if item2.name in blocksmap.keys():
+ if not layersmap or (layersmap and not layersmap[item2.layer][1]): #if insert_layer is not frozen
+ blocksmap[item2.name][0] = True # marked as world used BLOCK
key_list = blocksmap.keys()
key_list.reverse()
@@ -4789,10 +4597,12 @@ def drawer(_type, entities, settings, block_def): #----------------------------
group = getGroup('l:%s' % layernamesmap[entity.layer])
if _type == 'insert': #---- INSERT and MINSERT=array --------------------
- if not settings.var['block_nn'] and entity.name.startswith('*X'): #---- support for noname BLOCKs
- #print 'deb:drawer entity.name:', entity.name #------------
- continue
- elif settings.var['blockFilter_on'] and not settings.accepted_block(entity.name):
+ if not settings.var['block_nn']: #----turn off support for noname BLOCKs
+ prefix = entity.name[:2]
+ if prefix in ('*X', '*U', '*D'):
+ #print 'deb:drawer entity.name:', entity.name #------------
+ continue
+ if settings.var['blockFilter_on'] and not settings.accepted_block(entity.name):
continue
#print 'deb:insert entity.loc:', entity.loc #----------------
diff --git a/release/scripts/import_obj.py b/release/scripts/import_obj.py
index 3aad0800cf7..42cdac4dc35 100644
--- a/release/scripts/import_obj.py
+++ b/release/scripts/import_obj.py
@@ -424,8 +424,8 @@ def create_mesh(scn, new_objects, has_ngons, CREATE_FGONS, CREATE_EDGES, verts_l
sharp_edges[key]= None
- # mat the material names to an index
- material_mapping= dict([(name, i) for i, name in enumerate(unique_materials.keys())])
+ # map the material names to an index
+ material_mapping= dict([(name, i) for i, name in enumerate(unique_materials)]) # enumerate over unique_materials keys()
materials= [None] * len(unique_materials)
diff --git a/release/scripts/import_web3d.py b/release/scripts/import_web3d.py
index 28bc1a40ef0..87a259cbe56 100755
--- a/release/scripts/import_web3d.py
+++ b/release/scripts/import_web3d.py
@@ -1758,7 +1758,7 @@ def importMesh_IndexedFaceSet(geom, bpyima, ancestry):
print '\tWarning: per vertex color index out of range'
continue
- if len(ifs_vcol) < color_index:
+ if color_index < len(ifs_vcol):
c.r, c.g, c.b = ifs_vcol[color_index]
else:
#print '\tWarning: per face color index out of range'
diff --git a/release/scripts/ply_import.py b/release/scripts/ply_import.py
index 302e21a0a43..43129ec01e9 100644
--- a/release/scripts/ply_import.py
+++ b/release/scripts/ply_import.py
@@ -160,13 +160,16 @@ def read(filename):
obj_spec = object_spec()
try:
- file = open(filename, 'rb')
+ file = open(filename, 'rU') # Only for parsing the header, not binary data
signature = file.readline()
- if (signature != 'ply\n'):
+
+ if not signature.startswith('ply'):
print 'Signature line was invalid'
return None
+
while 1:
tokens = re.split(r'[ \n]+', file.readline())
+
if (len(tokens) == 0):
continue
if (tokens[0] == 'end_header'):
@@ -197,14 +200,22 @@ def read(filename):
obj_spec.specs[-1].properties.append(property_spec(tokens[4], type_specs[tokens[2]], type_specs[tokens[3]]))
else:
obj_spec.specs[-1].properties.append(property_spec(tokens[2], None, type_specs[tokens[1]]))
+
+ if format != 'ascii':
+ file.close() # was ascii, now binary
+ file = open(filename, 'rb')
+
+ # skip the header...
+ while not file.readline().startswith('end_header'):
+ pass
+
obj = obj_spec.load(format_specs[format], file)
-
+
except IOError, (errno, strerror):
try: file.close()
except: pass
return None
-
try: file.close()
except: pass
diff --git a/release/scripts/scripttemplate_gamelogic.py b/release/scripts/scripttemplate_gamelogic.py
index 7184d7e424f..01348e86d0a 100644
--- a/release/scripts/scripttemplate_gamelogic.py
+++ b/release/scripts/scripttemplate_gamelogic.py
@@ -11,6 +11,9 @@ import bpy
script_data = \
'''
+# This script must be assigned to a python controller
+# where it can access the object that owns it and the sensors/actuators that it connects to.
+
# GameLogic has been added to the global namespace no need to import
# for keyboard event comparison
@@ -50,7 +53,7 @@ def main():
for actu in cont.getActuators():
# The actuator can be on another object, we may want to use it
own_actu = actu.getOwner()
- print ' actuator:', sens.getName()
+ print ' actuator:', actu.getName()
# This runs the actuator or turns it off
# note that actuators will continue to run unless explicitly turned off.