pyyeti.nastran.op2.OP2.set_position¶
- OP2.set_position(pos, which=0)[source]¶
Set the op2 file position
- Parameters:
pos (integer or string) – If integer, it is the desired byte offset in the file. If a string, it is the name of the data block to position to; in this case, the which parameter is also used.
which (integer; optional) – If pos is a string, which is the index of the data block to seek to. For example, 0 is the first, -1 is the last.
- Returns:
integer – Byte offset in file (same as pos if integer)
Notes
The following two code snippets position to the start of the first KAA data block and read it in. The first gets the position the “hard way”:
o2 = op2.OP2('mds.op2') fpos = o2.dbdct['KAA'][0].start o2.set_position(fpos) name, trailer, rectype = o2.rdop2nt() kaa = o2.rdop2matrix(trailer)
The second uses the string feature of this routine:
o2 = op2.OP2('mds.op2') o2.set_position('KAA') name, trailer, rectype = o2.rdop2nt() kaa = o2.rdop2matrix(trailer)