So I wrote the following script to test changing the 'RS' result set to an 'S' result set.
It appears to work when looking at the console window, but my pre/post processor doesn't recognize that an additional step has been added.
Do I need to change something else in the ODB file for this? I'm not sure why the new step isn't seen when importing the new ODB file.
The "first ODB file" in the code below refers to the file with the random results, the "second ODB file" is the same model, but with just a 1g static load applied. I'm moving the RMS data to the 1G file just to have a smaller ODB to import when I'm done.
Thanks.
=======================
## Open First ODB File:
print '-'
print '-First ODB File: '
print '----------------'
##odbName=raw_input('Enter ODB File Name: ') ## (uncomment for user input)
##odbRandom=openOdb(path=odbName) ## (uncomment for user input)
odbRandom=openOdb(path="MDExample.odb")
## Print Step Names:
print '-'
print '-Steps:'
for stepName in odbRandom.steps.keys():
print ' ', stepName
print '-'
## Set Active Step:
##
##stepName=raw_input('Enter Step Name: ') ## (uncomment for user input)
##stepRandom=odbRandom.steps[stepName] ## (uncomment for user input)
stepRandom=odbRandom.steps['RandomDOF2']
print ' Selected Step = ', stepRandom.name
## Print Number of Frames:
numberOfFrames=len(stepRandom.frames)
print ' Number of Frames = ', numberOfFrames-1
## Set Active Frame:
frameRandom=stepRandom.frames[-1] ## automatically select last frame
print ' Selected Frame = ', frameRandom.frameId
## Load Results:
print '-'
print ' Results Found: '
for fieldName in frameRandom.fieldOutputs.keys():
print ' ', fieldName
##odbSelectResultsName=raw_input('Enter Results Name: ') ## (uncomment for user input)
##odbSelectResults=openOdb(path=odbSelectResultsName) ## (uncomment for user input)
odbSelectResults=frameRandom.fieldOutputs['RS']
print '-'
print ' Selected Results = ', odbSelectResults.name
##for s in odbSelectResults.values: ## Test to see data entries
## print s.elementLabel, s.data
## Open Second ODB File:
print '-'
print '-Second ODB File: '
print '-----------------'
##odbName=raw_input('Enter ODB File Name: ') ## (uncomment for user input)
##odbRandom=openOdb(path=odbName) ## (uncomment for user input)
odbWrite=openOdb(path="MDExample_1G.odb")
## Print Step Names:
print '-'
print '-Steps:'
for stepName in odbWrite.steps.keys():
print ' ', stepName
print '-'
## Set Active Step:
##
##stepName=raw_input('Enter Step Name: ') ## (uncomment for user input)
##stepRandom=odbRandom.steps[stepName] ## (uncomment for user input)
stepWrite=odbWrite.steps['StaticLoad']
print ' Selected Step = ', stepWrite.name
## Print Number of Frames:
numberOfFrames=len(stepWrite.frames)
print ' Number of Frames = ', numberOfFrames-1
## Set Active Frame:
frameWrite=stepWrite.frames[-1] ## automatically select last frame
print ' Selected Frame = ', frameWrite.frameId
## Load Results:
print '-'
print ' Results Found: '
for fieldName in frameWrite.fieldOutputs.keys():
print ' ', fieldName
##odbSelectResultsName=raw_input('Enter Results Name: ') ## (uncomment for user input)
##odbSelectResults=openOdb(path=odbSelectResultsName) ## (uncomment for user input)
odbWriteResults=frameWrite.fieldOutputs['S']
print '-'
print ' Selected Results = ', odbWriteResults.name
#for s in odbWriteResults.values: ## test to see data entries
# print s.elementLabel, s.data
## Combine Results:
newDataSet=odbSelectResults+odbWriteResults
## Save New Field:
newResultsStep=odbWrite.Step(name='Test',
description='User Defined Results',
domain=TIME,
timePeriod=0)
newResultsFrame=newResultsStep.Frame(incrementNumber=0,
frameValue=0.0)
newResultsField=newResultsFrame.FieldOutput(name='S',
description='User Defined Results',
type=TENSOR_3D_PLANAR)
newResultsField.addData(field=newDataSet)
odbWrite.save()
## Verify New Step is Written and Data is Entered:
##print '-'
##print '-Steps:'
##for stepName in odbWrite.steps.keys():
## print ' ', stepName
##print '-'
##print '-'
##print ' Results Found: '
##for fieldName in odbWrite.steps['Test'].frames[-1].fieldOutputs.keys():
## print ' ', fieldName
##for s in odbWrite.steps['Test'].frames[-1].fieldOutputs['S'].values:
## print s.elementLabel, s.data
## Close ODB files:
odbRandom.close()
odbWrite.close()