SM1994
Bioengineer
- Mar 25, 2020
- 49
Hello
I am trying to generate a Path in abaqus using a script, but instead of feeding the path as coordinate manually, I want abaqus read a CSV file and generate a path based on that, but I get the following error:
TypeError: expression;found 'file', expecting a recognized type filling string dict.
I understand the script does not recongnize the input file, but I do not know how should I modify it?
The CSV file is attached.
error happens in:
session.Path(name='point_list', type=POINT_LIST, expression=Data)
Thanks for your help in advance.
I am trying to generate a Path in abaqus using a script, but instead of feeding the path as coordinate manually, I want abaqus read a CSV file and generate a path based on that, but I get the following error:
TypeError: expression;found 'file', expecting a recognized type filling string dict.
I understand the script does not recongnize the input file, but I do not know how should I modify it?
The CSV file is attached.
error happens in:
session.Path(name='point_list', type=POINT_LIST, expression=Data)
Thanks for your help in advance.
Code:
.setValues(
# displayedObject=session.odbs['C:/temp/Job-6.odb'])
pressure_range={170e-3,70e-3,20e-3,120e-3}
void_range={2,4,6,8,10,12,14,16,17}
Thickness_range={8,12,16,20}
#pressure_range={20e-3}
#void_range={2}
#Thickness_range={8}
i=0
for void in void_range:
for Thickness in Thickness_range:
for Pressure_mag in pressure_range:
pressure_name=Pressure_mag*1000
pressure_name= int(pressure_name)
void_name=int(void)
Thickness_name=int(Thickness)
i=i+1
J_name='Job-'+str(i)+'Void_size'+str(void_name)+'mm'+'Thickness'+str(Thickness_name)+'mm'+str(pressure_name)+'Kpa_ogd'
ParentDir='W:/Saeed M/Abaqus results from NESI/1D_Model_3/Ver5/Model_3_ver5'+'/'
JobDir=J_name+'/'+J_name+'.odb'
JobDirectory=ParentDir+JobDir
CSV_name=J_name+'.csv'
CSVreadpath='W:/Saeed M/Abaqus results from NESI/1D_Model_3/Ver5/Model_3_ver5'
#file=open(CSVreadpath,"r")
with open ('Data.csv','r') as csv_file:
Data=csv.reader (csv_file)
o1 = session.openOdb(
name=JobDirectory)
session.viewports['Viewport: 1'].setValues(displayedObject=o1)
session.Path(name='point_list', type=POINT_LIST, expression=Data)
#----------------------------------------------- is the proposed method for automatically save the excel files---------
# Information obrained from: [URL unfurl="true"]https://www.eng-tips.com/viewthread.cfm?qid=391617[/URL]
session.viewports['Viewport: 1'].odbDisplay.setPrimaryVariable(
variableLabel='U', outputPosition=NODAL, refinement=(INVARIANT,
'Magnitude'), )
xyp = session.xyPlots['XYPlot-1']
chartName = xyp.charts.keys()[0]
chart = xyp.charts[chartName]
pth = session.paths['point_list']
xy1 = xyPlot.XYDataFromPath(path=pth, includeIntersections=False,
projectOntoMesh=False, pathStyle=PATH_POINTS, numIntervals=10,
projectionTolerance=0, shape=UNDEFORMED, labelType=TRUE_DISTANCE)
c1 = session.Curve(xyData=xy1)
chart.setValues(curvesToPlot=(c1, ), )
session.viewports['Viewport: 1'].setValues(displayedObject=xyp)
session.xyPlots[session.viewports['Viewport: 1'].displayedObject.name].setValues(
transform=(0.49697, 0, 0, -0.304173, 0, 0.49697, 0, -0.174628, 0, 0,
0.49697, 0, 0, 0, 0, 1))
pth = session.paths['point_list']
D=session.XYDataFromPath(name='Job_data', path=pth, includeIntersections=False,
projectOntoMesh=False, pathStyle=PATH_POINTS, numIntervals=10,
projectionTolerance=0, shape=UNDEFORMED, labelType=TRUE_DISTANCE)
session.xyPlots[session.viewports['Viewport: 1'].displayedObject.name].setValues(
transform=(0.704961, 0, 0, -0.0658641, 0, 0.704961, 0, -0.169147, 0, 0,
0.704961, 0, 0, 0, 0, 1))
import sys
#sys.path.insert(9,
# r'c:/SIMULIA/Abaqus/6.14-2/code/python2.7/lib/abaqus_plugins/excelUtilities')
#import abq_ExcelUtilities.excelUtilities
#abq_ExcelUtilities.excelUtilities.XYtoExcel(xyDataNames='Job_data',
# trueName='From Current XY Plot')
#: XY Data sent to Excel
#odb = session.odbs['C:/SIMULIA/Temp/Job-5.odb']
#session.viewports['Viewport: 1'].setValues(displayedObject=odb)
#session.viewports['Viewport: 1'].odbDisplay.display.setValues(plotState=(
# CONTOURS_ON_DEF, ))
import win32com.client
from win32com.client import constants
#xl = win32com.client.Dispatch("Excel.Application") #Fetch the application and assign it to a variable. You can now interact with excel using python/VBA.
#xl.DisplayAlerts=False #Get rid of popup alerts that will prevent some scripts from running.
#xl.Visible = 1 #Shows the excel app window, useful if you want to mess around issuing commands from the Abaqus GUI and observing what happens in the workbook.
#xlBook = xl.Workbooks.Add() #Similar to what Abaqus does, creates a 'Book1'.
#xlSheet = xlBook.Sheets(1) #Access a worksheet
#xlSheet.Cells(1,1).Value #Modify cell contents.
#xlBook.SaveAs(Filename='Name', FileFormat='Format') #Here is the save command you were looking for.
#xlBook.SaveAs("C:/test.xls")
#x0 = session.xyDataObjects['S:Mises PI: PART-1-1 E: 4309 IP: 1']
session.writeXYReport(fileName=CSV_name, xyData=(D, ))]