I'm having some issues when I import .inp
models into Abaqus CAE. I defined this new input file starting from an original input file, and changing the values of some parameters via a Python loop that works fine and produces the new .inp
I need.
The fact is that when I try to import the new input files into CAE, it doesn't work and the error NoKeywordsDefinedError appears. The funny fact is that if I copy and paste the content of the new .inp
file into the old one, and I import that model, well, it works.
I defined the new .inp
using in this way:
inputFile=open('Job-1.inp','r')
outputFile=open('ModifiedInput'+'_RUN'+str(run)+'_LEVEL'+str(r)+'.inp','w')
number_of_lines = 0
for line in inputFile:
line = line.strip("\n")
number_of_lines += 1
if number_of_lines == XXX:
line = line.replace('old','new')
outputFile.write(line)
Maybe I should specify something when I write the lines into the new file?
A few things you could do to improve your script:
outputFile.write
statement outside of the number_of_lines
check.inputFile=open('Job-1.inp','r')
outputFile=open('ModifiedInput'+'_RUN'+str(run)+'_LEVEL'+str(r)+'.inp','w')
number_of_lines = 0
for line in inputFile:
#line = line.strip("\n")
number_of_lines += 1
if number_of_lines == XXX:
line = line.replace('old','new')
outputFile.write(line)
inputFile.close()
outputFile.close()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.