how to use scripting for writing field output reports?
how to use scripting for writing field output reports?
(OP)
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!
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!





RE: how to use scripting for writing field output reports?
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()
RE: how to use scripting for writing field output reports?
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.
RE: how to use scripting for writing field output reports?
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'), )), ))
RE: how to use scripting for writing field output reports?
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!
RE: how to use scripting for writing field output reports?
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.
RE: how to use scripting for writing field output reports?