[Bf-python] svg2obj script.
Campbell Barton
cbarton at metavr.com
Thu Mar 29 01:48:55 CEST 2007
jmsoler at free.fr wrote:
> http://jmsoler.free.fr/util/blenderfile/py/svg2obj_059.py
>
> 0.5.9 : - many improvements for faster and clearer code
> suggested by cambo and martin.
> - replacement of "%s" statement by str function.
> - correction of an error in the scale transform management
> - correction in the management of the stack transformation
> that rise an error under python 2.5 but curiously not with
> python 2.4
>
> jms
Hi JMS, some changes
http://members.optusnet.com.au/cjbarton/svg2obj.py
Heres a patch, ignore the first 2 filenames.
--- /bs_/bpymodules/svg2obj.py
+++ /tmp/svg2obj_059-1.py
@@ -291,7 +291,7 @@
# ----------
# 0.4.7
# ----------
- if nom.upper().endswith('.SVGZ'):
+ if '.SVGZ' in nom.upper(): #.find('.SVGZ')!=-1:
try :
import gzip
tz=gzip.GzipFile(nom)
@@ -424,7 +424,7 @@
del val.beziers_knot[-1]
#print 'remove last point', rmp
#rmp+=1
- for k2 in xrange(0,len(val.beziers_knot)):
+ for k2 in range(0,len(val.beziers_knot)):
bz= [co for co in val.beziers_knot[k2].co]
if bzn==0:
cp1 = bz[4],bz[5],0.0 , bz[0],bz[1],0.0, bz[2],bz[3],0.0,
@@ -487,15 +487,15 @@
except:
pxUNIT['%']=(BOUNDINGBOX['rec'][3]-BOUNDINGBOX['rec'][1])/100.0
for key in pxUNIT:#.keys():
- if key in prp['height']:
- height=float(prp['height'].replace(key,''))*pxUNIT[key]
+ if key in prp['height']:
+ height=float(prp['height'].replace(key,''))*pxUNIT[key]
try:
width=float(prp['width'])
except:
pxUNIT['%']=(BOUNDINGBOX['rec'][2]-BOUNDINGBOX['rec'][0])/100.0
for key in pxUNIT:#.keys():
if key in prp['width']:
- width=float(prp['width'].replace(key,''))*pxUNIT[key]
+ width=float(prp['width'].replace(key,''))*pxUNIT[key]
#--------------------
# 0.5.8, end
#--------------------
@@ -671,7 +671,7 @@
ang_arc-=2.0*PI
n_segs=int(ceil(abs(ang_arc*2.0/(PI*0.5+0.001))))
P=[]
- for i in xrange(n_segs):
+ for i in range(n_segs):
ang0=ang_0+i*ang_arc/n_segs
ang1=ang_0+(i+1)*ang_arc/n_segs
ang_demi=0.25*(ang1-ang0)
@@ -991,7 +991,7 @@
if i==-1: break
tagplace.append(i)
b1=i+1
-
+
# ----------------------------------------
# reset the list in the presentation order
# of the data
@@ -1014,7 +1014,7 @@
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)
+ for n in ndata : DATA2.append(n)
else:
#--------------------
# 0.3.5 : short data,only one tag
@@ -1104,7 +1104,7 @@
nt0=txt[t0:t1+1]
t2=nt0[nt0.find('(')+1:-1]
val=nt0[:nt0.find('(')]
- while ' ' in t2:
+ while t2.find(' ')!=-1:
t2=t2.replace(' ',' ')
t2=t2.replace(' ',',')
t2=t2.split(',')
@@ -1162,13 +1162,14 @@
bez=bez0.co
for b in [0,2,4]:
for t in ST:
- v = t * Mathutils.Vector([bez[b],bez[b+1],1.0])
+ v=Mathutils.Vector([bez[b],bez[b+1],1.0])
+ v=t * v
bez[b]=v[0]
bez[b+1]=v[1]
def filter(d):
for nn in d:
- if nn not in '0123456789.':
+ if '0123456789.'.find(nn)==-1:
d=d.replace(nn,"")
return d
@@ -1225,8 +1226,8 @@
TRANSFORM=0
t=t.replace('\t',' ')
- while ' ' in t: t=t.replace(' ',' ')
- n0=0
+ while t.find(' ')!=-1: t=t.replace(' ',' ')
+ n0=0
t0=t1=0
baliste=[]
balisetype=['?','?','/','/','!','!']
More information about the Bf-python
mailing list