Python script in abaqus error: 'numpy.ndarray' object has no attribute 'setValues'
Python script in abaqus error: 'numpy.ndarray' object has no attribute 'setValues'
基本上,我正在尝试输出包含两个数据 x0 和 x1 的报告。我遵循 Abaqus .rpy 格式并尝试重命名计算变量,但它给了我这个错误。
- AttributeError: 'numpy.ndarray' 对象没有属性 'setValues' 第 72 行,在
xy2.setValues(sourceDescription='s + "U3 PI: PLATE-1 N: 40402 NSET RP-1"')
(行号与下面代码中提供的不同。)
from abaqus import *
from abaqusConstants import *
from caeModules import *
import random
import mesh
import time
import odbAccess
import visualization
session.XYDataFromHistory(name='U3 PI: PLATE-1 N: 40402 NSET RP-1', odb=odb,
outputVariableName='Spatial displacement: U3 PI: PLATE-1 Node 40402 in NSET RP',
steps=('compression', ), __linkedVpName__='Viewport: 1')
xy1 = session.xyDataObjects['U3 PI: PLATE-1 N: 40402 NSET RP-1']
xy2 = s+xy1
xy2.setValues(sourceDescription=' s + "U3 PI: PLATE-1 N: 40402 NSET RP-1"')
tmpName = xy2.name
session.xyDataObjects.changeKey(tmpName, 'XYData-1')
x0=session.XYDataFromHistory(name='RF3 PI: PLATE-1 N: 40402 NSET RP-1', odb=odb,
outputVariableName='Reaction force: RF3 PI: PLATE-1 Node 40402 in NSET RP',
steps=('compression', ), __linkedVpName__='Viewport: 1')
x1 = session.xyDataObjects['XYData-1']
session.writeXYReport(fileName='Thickness_Estimation.rpt', xyData=(x0, x1), appendMode=OFF)
请告诉我如何解决这个问题。
找到了这个问题的答案。我只需要将 xy2
转换为 XY 数据对象。
xy1 = session.xyDataObjects['U3 PI: PLATE-1 N: 40402 NSET RP-1']
xy2Data=[]
for datapoint in xy1.data:
xy2Data.append([datapoint[0], datapoint[1]+s])
xQuantity = visualization.QuantityType(type=TIME)
yQuantity = visualization.QuantityType(type=DISPLACEMENT)
session.XYData(name='Distance', data=xy2Data,
sourceDescription='s+U3', axis1QuantityType=xQuantity,
axis2QuantityType=yQuantity, )
xy2 = session.xyDataObjects['Distance']
x0=session.XYDataFromHistory(name='RF3 PI: PLATE-1 N: 40402 NSET RP-1',
odb=odb,
outputVariableName='Reaction force: RF3 PI: PLATE-1 Node 40402 in NSET RP',
steps=('compression', ), __linkedVpName__='Viewport: 1')
session.writeXYReport(fileName='Load_Caliper.rpt', xyData=(x0,xy2),
appendMode=OFF)
基本上,我正在尝试输出包含两个数据 x0 和 x1 的报告。我遵循 Abaqus .rpy 格式并尝试重命名计算变量,但它给了我这个错误。
- AttributeError: 'numpy.ndarray' 对象没有属性 'setValues' 第 72 行,在 xy2.setValues(sourceDescription='s + "U3 PI: PLATE-1 N: 40402 NSET RP-1"')
(行号与下面代码中提供的不同。)
from abaqus import *
from abaqusConstants import *
from caeModules import *
import random
import mesh
import time
import odbAccess
import visualization
session.XYDataFromHistory(name='U3 PI: PLATE-1 N: 40402 NSET RP-1', odb=odb,
outputVariableName='Spatial displacement: U3 PI: PLATE-1 Node 40402 in NSET RP',
steps=('compression', ), __linkedVpName__='Viewport: 1')
xy1 = session.xyDataObjects['U3 PI: PLATE-1 N: 40402 NSET RP-1']
xy2 = s+xy1
xy2.setValues(sourceDescription=' s + "U3 PI: PLATE-1 N: 40402 NSET RP-1"')
tmpName = xy2.name
session.xyDataObjects.changeKey(tmpName, 'XYData-1')
x0=session.XYDataFromHistory(name='RF3 PI: PLATE-1 N: 40402 NSET RP-1', odb=odb,
outputVariableName='Reaction force: RF3 PI: PLATE-1 Node 40402 in NSET RP',
steps=('compression', ), __linkedVpName__='Viewport: 1')
x1 = session.xyDataObjects['XYData-1']
session.writeXYReport(fileName='Thickness_Estimation.rpt', xyData=(x0, x1), appendMode=OFF)
请告诉我如何解决这个问题。
找到了这个问题的答案。我只需要将 xy2
转换为 XY 数据对象。
xy1 = session.xyDataObjects['U3 PI: PLATE-1 N: 40402 NSET RP-1']
xy2Data=[]
for datapoint in xy1.data:
xy2Data.append([datapoint[0], datapoint[1]+s])
xQuantity = visualization.QuantityType(type=TIME)
yQuantity = visualization.QuantityType(type=DISPLACEMENT)
session.XYData(name='Distance', data=xy2Data,
sourceDescription='s+U3', axis1QuantityType=xQuantity,
axis2QuantityType=yQuantity, )
xy2 = session.xyDataObjects['Distance']
x0=session.XYDataFromHistory(name='RF3 PI: PLATE-1 N: 40402 NSET RP-1',
odb=odb,
outputVariableName='Reaction force: RF3 PI: PLATE-1 Node 40402 in NSET RP',
steps=('compression', ), __linkedVpName__='Viewport: 1')
session.writeXYReport(fileName='Load_Caliper.rpt', xyData=(x0,xy2),
appendMode=OFF)