Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to use scripting for writing field output reports? 1

Status
Not open for further replies.

fdsssr

Civil/Environmental
Feb 19, 2007
4
Hello members,
I am new here, and a beginner in scripting. So my problem is that I want to write field output reports, in large numbers, each frame in a different .rpt. I thought i could easily use a script and a loop, but I absolutely don't understand how python works. Anyway I found the function that probably does what I want, it's "writeFieldReport". But when I try to run a script with that function and its arguments, I still have that message "IOError: Empty filename".

I put hereunder what i wrote:

myViewport = session.Viewport(name='Essai')
odbPath = 'hydro-mulet-2.odb'
myOdb = visualization.openOdb(path=odbPath)
myViewport.setValues(displayedObject=myOdb)
myOutputFile = open('hydro-mulet-2-s1f01.rpt','w')
session.writeFieldReport(filename='myOutputFile',
append=OFF,sortItem='Element Label',odb=myOdb,step=1,frame=1,
outputPosition=WHOLE_ELEMENT,variable=['EVOL',WHOLE_ELEMENT,(COMPONENT,'EVOL')])

myOutputFile.close

Please help me correct the wrong arguments: I especially don't understand how to handle the filename and displayGroup (it seems to be requested but I don't know what to write! I simply want "All").

Thanks!
 
Replies continue below

Recommended for you

Some Remarks:

You have to distinguish between a file object and its name.
In your case myOutputFile is a file object and its name is 'hydro-mulet-2-s1f01.rpt'.

You can see his name by
print myOutputFile.name

In session.session.writeFieldReport(filename='...',..) you are requested to supply the name of a file where the report should be output to.

Also: myOutputFile.close
should be myOutputFile.close()




 
you're right, xerf, but seeing that the problem was linked with the filename, I had already tried all the solutions around this, especially this one.

So, my new code is:

myViewport = session.Viewport(name='Essai')
odbPath = 'hydro-mulet-2.odb'
myOdb = visualization.openOdb(path=odbPath)
myViewport.setValues(displayedObject=myOdb)
myOutputFile = open('hydro-mulet-2-s1f01.rpt','w')
session.writeFieldReport(filename='hydro-mulet-2-s1f01.rpt',
append=OFF,sortItem='Element Label',odb=myOdb,step=1,frame=1,
outputPosition=WHOLE_ELEMENT,displayGroup='All',
variable=['EVOL',WHOLE_ELEMENT,(COMPONENT,'EVOL')])

myOutputFile.close()

And the error is still IOError: Empty filename. What's strange is the line given for the error: it says that the error is in the line "variable=...". Could there be a mistake in this argument? It's possible because its syntax is quite complicated but I don't see the problem, and it doesn't say "syntax error".

Do you know if I need to open and close the file I want to write in with this command? The fact that I do or do not open/close it doesn't change the error.

Did anybody ever use this python command??
Thanks.
 
Remarks:
displayGroup= should be
"A DisplayGroup object specifying the subset of the model for which to obtain data." and not a string.

you should use
displayGroup=session.displayGroups['All']

I am not sure if you have to explicitly open the file before
session.writeFieldReport

I have not used session.writeFieldReport so far, instead I preferred to write code which extracts the information from the FieldOutput objects. I think this happened because session.writeFieldReport was causing ABAQUS to crash.

You definitly must start using the Scripting Reference Manual to see the type of each argument.

To get some clues on a complex scripting syntax, you can perform the equivalent tasks from CAE menus. Abaqus records these tasks as Python code in a file abaqus.rpy.

For example, the next code was recorded as I used the menu to create a report based on SDV10.

o1 = session.openOdb(name='C:/Temp/trans_p100_E8-8_SY200_N1-INIT-T0-T1.odb')
session.viewports['Viewport: 1'].setValues(displayedObject=o1)
odb = session.odbs['C:/Temp/trans_p100_E8-8_SY200_N1-INIT-T0-T1.odb']
session.writeFieldReport(fileName='abaqus1.rpt', append=ON,
sortItem='Element Label', odb=odb, step=1, frame=100,
outputPosition=INTEGRATION_POINT, variable=(('SDV10', INTEGRATION_POINT), ))


and this for writing S11, S22, S33, S12 and Mises.

session.writeFieldReport(fileName='abaqus1.rpt', append=ON,
sortItem='Element Label', odb=odb, step=1, frame=100,
outputPosition=INTEGRATION_POINT, variable=(('S', INTEGRATION_POINT, ((INVARIANT, 'Mises'), COMPONENT, 'S11'), (COMPONENT, 'S22'), (COMPONENT,'S33'), (COMPONENT, 'S12'), )), ))
 
great thing that abaqus.rpy file! I think I'll get my solution that way. I did not know about it.

In fact, I read precisely the Scripting Reference Manual, but as you can see in your own answer, some arguments that are supposed to be "required" are not required in fact.
I think my displayGroup was working anyway (even if your solution is somehow cleaner), because: first it gives a specific error message if I write something wrong, and second because when I make "print session.displayGroups", it returns 'All', as a displayGroup object. Anyway this argument is not required in fact.

And I've not been convinced at all by the way the manual is made (the rest of the documentation is great in my opinion, but scripting manual is really poor to me).

But the replay file is definitely a great tool!! thanks a lot!
 
Actually,

session.displayGroups is a repository (sort of a dictionary).

'All' is just a string representing the name of a displayGroup object.

I am glad I could help.
 
So, the job is done! but one interesting point is that the replay file doesn't mention the opening of the file for writing. BUT I had to explicitely open and close my files to get it working as a script. Strangely it did not return an error message; but the files were not written. I simply added the open and close commands and it now works!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor