- 积分
- 0
- 注册时间
- 2010-11-4
- 仿真币
-
- 最后登录
- 1970-1-1
|
本帖最后由 lovebbtyf 于 2010-12-20 12:57 编辑
我在建立模型的时候,就建立了如下,1个节点集,但是问题在于,这个程序总是出错,我分别输出len(nSet.nodes)的大小是31的,输出这句n = nSet.nodes【i】,值是我选中的最后一个节点。({'coordinates': array([12.0, -8.0, 0.0], 'd'), 'instanceName': 'PART-1-1', 'label': 931}) 我查看了是对的。 当我改变i的值, print nSet.nodes[2],输出的是我选中的第三个节点,({'coordinates': array([12.0, 6.93333339691162, 0.0], 'd'), 'instanceName': 'PART-1-1', 'label': 63})也没有什么问题,但是,label = n.label,coord = n.coordinates怎么显示说有语法错误啊?跪求高手解答一下,下面的程序有什么问题啊?而且整个运行就是有错误的,一行一行试到label = n.label,coord = n.coordinates也出现问题了。
#p = mdb.models['Model-1'].parts['Part-1']
#n = p.nodes
#nodes = n.getSequenceFromMask(mask=(
# '[#80000001 #40000000 #20000000 #10000000 #8000000 #4000000 #2000000',
# ' #1000000 #800000 #400000 #200000 #100000 #80000 #40000',
# ' #20000 #10000 #8000 #4000 #2000 #1000 #800',
# ' #400 #200 #100 #80 #40 #20 #10', ' #8 #4 ]', ), )
#p.Set(nodes=nodes, name='Set-1')
以下是程序
# -*- coding: cp936 -*-
# -------------------------
from abaqusConstants import *
from symbolicConstants import *
import odbAccess
import os
import string
vpName = session.currentViewportName
odb = session.viewports[ vpName ].displayedObject
nSet = odb.rootAssembly.instances['PART-1-1'].nodeSets['SET-1']
stepNum = -1
FrameNum = -1
# Get nodes list
nodeList = []
nLabelList = []
for i in range(len(nSet.nodes)):
n = nSet.nodes【i】
label = n.label
coord = n.coordinates
nodeList.append( [ label, coord ] )
nLabelList.append( label )
nodeList.sort()
nLabelList.sort()
# Get steps list
stepList = []
for stepName in odb.steps.keys():
s = odb.steps[ stepName ]
stepList.append( [ s.number, stepName ] )
stepList.sort()
# Get field output and calulate the deformed coordinates
stepName = stepList[ stepNum ][1]
fo = odb.steps[ stepName ].frames[ FrameNum ].fieldOutputs['U'].getSubset( region=nSet )
Uvalue = fo.values
uNum = len( Uvalue[0].data )
nNum = len( nLabelList )
nCoord_deformed = []
for i in range( nNum ):
coord = []
for j in range( uNum ):
coord.append( nodeList[1][j] + Uvalue.data[j] )
nCoord_deformed.append( coord )
## output .csv file
csvFileName = odb.name[0:-4]+"_COORD_NodeSet="+nSet.name+"_Step="+stepName+"_Frame="+str(FrameNum)+".csv"
csvFile = open( csvFileName, 'w' )
csvFile.write( "Node ID,COORD_x,COORD_y,COORD_z\n" )
for i in range( nNum ):
csvFile.write( str(nLabelList) )
for j in range( uNum ):
#csvFile.write( ","+str(Uvalue.data[j]) )
csvFile.write( ","+str(nCoord_deformed[j]) )
csvFile.write( '\n' )
csvFile.close() |
|