IV.2.8.2 Printing Coordinate System Table Matrix
The example is provided in “RUBY/EX22/recoverCSTM.rb”. The interesting part of the example is
the use of the iterator:
db.iter_xdbRaw(xdbFileName,["CSTM",0],"iiffffffffffffifffffffff").each do |tab|
STDOUT.printf("Coordinate system ID: %d' n",tab[0])
STDOUT.printf("Coordinate system type: %d' n",tab[1])
STDOUT.printf("Coordinate system origin (wrt 0): %14g %14g %14g' n",
tab[2],tab[3],tab[4])
STDOUT.printf("Coordinate system V1 (wrt 0) : %14g %14g %14g' n",
tab[5],tab[6],tab[7])
STDOUT.printf("Coordinate system V2 (wrt 0) : %14g %14g %14g' n",
tab[8],tab[9],tab[10])
STDOUT.printf("Coordinate system V3 (wrt 0) : %14g %14g %14g' n",
tab[11],tab[12],tab[13])
end
Note that the CSTM table correspond to a FEM modeling table and not to a result table. This shows
that the raw access to XDB file can be used to access modeling information.
Generally, maximum one table per type is defined in XDB file, if the table corresponds to
modeling information. However, this is sometimes different. For example FEM modeling table may
correspond to an output of optimization run.
One also presents an example in which the ‘each_xdbBinRaw” iterator is used with
“binDataToValues” singleton method to interpret the content of XDB file. The example is provided in
“RUBY/EX22/recoverBINRAW.rb” script and its main part looks as follows:
wdSize=db.getAttachmentWordsSize(xdbFileName)
bSwap=db.getAttachmentSwapEndianness(xdbFileName)
policy=0
if (bSwap) then
policy=1
end
bAutoSwap=true
cards=[]
db.each_xdbBinRaw(xdbFileName,["CQD4",0],bAutoSwap) do |str|
arri=NastranDb.binDataToValues(str,wdSize,"iiiiiiii iiiii".delete(’ ’),policy)
arrf=NastranDb.binDataToValues(str,wdSize,"iiiiiiff fiiii".delete(’ ’),policy)
puts arri.size()
card=["CQUAD4"]+arri
#~ puts arri,arrf
cards << card
end
NastranDb.writeNastranCards("output.bdf","w","right","wide",cards)
Note that we output the read values into a kind of BDF file, but you will notice that the cards do not
really match the corresponding CQUAD4 card definition. you may notice that we also use the
getAttachmentWordsSize and getAttachmentSwapEndianness methods to determine the endianness
policy for binary data translation.