A Python script to extract information from a Nastran XDB file
Purpose of the script
The script illustrates the extraction of information from a Nastran XDB file.
Script
Python
import sys
sys.stdout=open(__file__+".log", 'w')
from FeResPost import *
import sys
sys.path.insert(0, '../UTIL')
import Util
# Creates and initializes the DataBase :
db=NastranDb()
db.Name="tmpDB"
db.readBdf("../../MODEL/MAINS/unit_xyz.bdf")
db.readGroupsFromPatranSession("../../MODEL/PATRAN/groups.ses")
# Accessing Results :
xdbFileName="../../MODEL/EXEC_XDB/sol111_ri_xyz.xdb"
db.attachXdb(xdbFileName)
infos=db.getAttachmentLcInfos(xdbFileName)
for tab in infos:
sys.stdout.write("%-20s %-25s %-6d %-6d %-15g %-15g\n"%(tab[0],tab[1],tab[3],tab[4],tab[5],tab[6]))
resNames=db.getAttachmentResNames(xdbFileName)
for resName in resNames:
sys.stdout.write("%-20s\n"%(resName))
Explanation
The different steps of the script are:
- The access to the FeResPost
compiled library.
- The creation of a NastranDb FEM database, into which the model and the groups are read.
- The attachment of a Nastran XDB file to the database.
- Information is extracted from the XDB file by calling the "getAttachmentLcInfos" method of the
NastranDb class, and printed to standard output.
- The list of result names found in the XDB file is also extracted with the "getAttachmentResNames" method, and printed to standard output.
References
More information on this example, and on the functions it uses, is given in the FeResPost User Manual.