- 积分
- 0
- 注册时间
- 2002-6-1
- 仿真币
-
- 最后登录
- 1970-1-1
|
发表于 2014-1-23 21:59:27
|
显示全部楼层
来自 江苏苏州
p是一个part
p.WirePolyLine(points=xyz, mergeWire=OFF, meshable=ON)
def boomCreate(model,pipeLine):
if pipeLine[0][12]==1:
boomName='mainBoom'
elif pipeLine[0][12]==2:
boomName='jib'
elif pipeLine[0][12]==3:
boomName='frontMast'
elif pipeLine[0][12]==4:
boomName='rearMast'
elif pipeLine[0][12]==5:
boomName='superMast'
p=model.Part(name=boomName)
sec=pipeLine[0][15]
pipeType=pipeLine[0][11]
startRow=0
n=len(pipeLine)
nn=0
## t0=time.time()
print boomName+' start creating'
for k in range(n):
t=pipeLine[k]
if sec!=t[15] or pipeType!=t[11]:
endRow=k
xyz=[]
midPoint=[]
for line in pipeLine[startRow:endRow]:
x1=line [0:3]
x2=line [3:6]
xyz.append((x1,x2))
midPoint.append(line [16:19])
pipeSet=p.WirePolyLine(points=xyz, mergeWire=OFF, meshable=ON)
setName=p.name+ '_'+str(int(pipeType)) +'_sec_'+str(int(sec))
secName='sec-'+str(int(sec))
f=findEdge(p,midPoint,setName)
## if not (len(f.edges)== len(midPoint)):
## print p.name,len(midPoint),len(f.edges),'----section line numer error, sec ',sec,' ,pipeType---' ,pipeType
## else:
## print p.name,len(midPoint),len(f.edges),'----section line ',sec,' ,pipeType---' ,pipeType
p.SectionAssignment(region=f, sectionName=secName, offset=0.0,
offsetType=MIDDLE_SURFACE, offsetField='',
thicknessAssignment=FROM_SECTION)
startRow=k
sec=t[15]
pipeType=t[11]
xyz=[]
midPoint=[]
for line in pipeLine[startRow:]:
x1=line [0:3]
x2=line [3:6]
xyz.append((x1,x2))
midPoint.append(line [16:19])
pipeSet=p.WirePolyLine(points=xyz, mergeWire=OFF, meshable=ON)
setName=p.name+ '_'+str(int(line[11])) +'_sec_'+str(int(line[15]))
secName='sec-'+str(int(line[15]))
f=findEdge(p,midPoint,setName)
if not (len(f.edges)== len(midPoint)):
print p.name,len(midPoint),len(f.edges),'----section line numer error, sec ',sec,' ,pipeType---' ,line[11]
else:
print p.name,len(midPoint),len(f.edges),'----section line ',sec,' ,pipeType---' ,pipeType
p.SectionAssignment(region=f, sectionName=secName, offset=0.0,
offsetType=MIDDLE_SURFACE, offsetField='',
thicknessAssignment=FROM_SECTION)
edges = p.edges
if not (len(edges)==len(pipeLine)):
print p.name,'--num error,pipeLine--',len(pipeLine),' ,edges---',len(edges)
region=regionToolset.Region(edges=edges)
p.assignBeamSectionOrientation(region=region, method=N1_COSINES, n1=(0.0, 1.0, -1.0))
p.seedPart(size=0.6, deviationFactor=0.1, minSizeFactor=0.1)
p.generateMesh()
## t1=time.time()
## ## print boomName,'generateMesh',t1-t0
## t0=time.time()
## chords and lattices
xyz=[ line[16:19] for line in pipeLine if line[11]==1]
if len(xyz):
s2=findEdge(p,xyz,'chords')
eAll=[]
for ed in s2.edges:
es=ed.getElements()
if len(es)>1:
e=es[1]
else:
e=es[0]
eAll.append(e.label)
s=p.elements.sequenceFromLabels(eAll)
p.Set(name='chordsElement',elements=s)
xyz=[ line[16:19] for line in pipeLine if line[11]==2]
if len(xyz):
s2=findEdge(p,xyz,'lattices')
eAll=[]
for ed in s2.edges:
es=ed.getElements()
if len(es)>1:
e=es[1]
else:
e=es[0]
eAll.append(e.label)
s=p.elements.sequenceFromLabels(eAll)
p.Set(name='latticesElement',elements=s)
print boomName+' start created' |
|