-2

Basically, I am trying to output a report with the two data x0 and x1. I followed the Abaqus .rpy format and tried to rename the calculated variable, but it is giving me this error.

  • AttributeError: 'numpy.ndarray' object has no attribute 'setValues' line 72, in xy2.setValues(sourceDescription=' s + "U3 PI: PLATE-1 N: 40402 NSET RP-1"')

(The line number is different than the one provided in the code below.)

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) 

Kindly let me know how to overcome this issue.

Schneider
  • 37
  • 1
  • 8
  • Please provider the _complete_ error message. – DYZ Apr 10 '18 at 00:24
  • Hi, the error is : #* AttributeError: 'numpy.ndarray' object has no attribute 'setValues' #* File "C:/Users/bhowmick.s/Desktop/odb_caliper_comp/lsf.1037735/RF_U3.py", #* line 72, in #* xy2.setValues(sourceDescription=' s + "U3 PI: PLATE-1 N: 40402 NSET #* RP-1"' (line number is different in the part of the code provided) – Schneider Apr 10 '18 at 00:31
  • Please make it a part of the question where it belongs and where it could be formatted. – DYZ Apr 10 '18 at 00:33
  • Your code doesn't specify what `s` is in `xy2 = s+xy1`. If you used the `+` operator to add the values of `xy1` (which is type `xyData`) to `s` (which I'm guessing is a NumPy array), then the sum `s+xy1` will be converted into a NumPy array, which does not have an attribute `setValues`. You need to convert `s` into an `xyData` object first for this code to work. – dROOOze Apr 10 '18 at 02:57
  • Hi @droooze, thanks. I have used the **+** operator. Yes, 's' is a numpy array. How to convert s into xyData object? I am a beginner in python so this might be a basic question. – Schneider Apr 10 '18 at 03:50
  • You're modifying the session objects directly with `setValues`, so there's no reason to create both `xy1` and `xy2` as references. Try running `xy1.setValues(s + xy1)`. – dROOOze Apr 10 '18 at 04:01
  • The `XYDataObject` has the data pairs in something in like `[(x1,y1),(x2,y2),...]` so if I do `xy1.setValues(s + xy1)` it adds to both the `x` and `y` columns. I want the addition to happen in the `y` column only, so I can later use the `XYReport` object. In that object, attribute `xyData` can only have `XYDataObjects`. – Schneider Apr 10 '18 at 14:57
  • Then make the first value of `s` equal to `0`, so you're adding `0` to `x1, x2, ...` – dROOOze Apr 11 '18 at 02:09

1 Answers1

0

Found an answer to this. I just needed to convert xy2 into an XY dataObject.

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) 
Schneider
  • 37
  • 1
  • 8