bdf/field_writer Package

This is the pyNastran.bdf.field_writer.rst file.

field_writer Module

Defines legacy import functions

pyNastran.bdf.field_writer.print_card(fields, size=8, is_double=False)[source]

Prints a card in 8-character of 16-character Nastran format.

Parameters:
fields : List[int/float/str/None]

all the fields in the BDF card (no trailing Nones)

size : int; default=8

the size of the field (8/16)

is_double : bool; default=False

is the card double precision? Double precision applies to specific cards and turns 1.234E+5 into 1.234D+5. Applies to GRID, CORDx only?

Returns:
card : str

string representation of the card

Note

be careful of using is_double on cards that aren’t GRID or CORDx

field_writer_8 Module

Defines functions for single precision 8 character field writing.

pyNastran.bdf.field_writer_8.is_same(value1, value2)[source]

Checks to see if 2 values are the same

Note

this method is used by almost every card when printing

pyNastran.bdf.field_writer_8.print_card_8(fields)[source]

Prints a nastran-style card with 8-character width fields.

Parameters:
fields : List[int/float/str/None]

all the fields in the BDF card (no trailing Nones)

Returns:
card : str

string representation of the card in small field format

Note

An internal field value of None or ‘’ will be treated as a blank field

Note

A small field format follows the 8-8-8-8-8-8-8-8 = 80 format where the first 8 is the card name or blank (continuation). The last 8-character field indicates an optional continuation, but because it’s a left-justified unneccessary field, print_card doesnt use it.

pyNastran.bdf.field_writer_8.print_field_8(value)[source]

Prints a 8-character width field

Parameters:
value : int/float/str

the value to print

Returns:
field : str

an 8-character string

pyNastran.bdf.field_writer_8.print_float_8(value)[source]

Prints a float in nastran 8-character width syntax using the highest precision possbile.

pyNastran.bdf.field_writer_8.print_int_card(fields)[source]

Prints a nastran-style card with 8-character width fields. All fields (other than the first field) must be integers. This is used to speed up SET cards.

Parameters:
fields : List[int/float/str/None]

The list of fields to write to a nastran card.

.. warning::

Blanks are not allowed! Floats and strings are not allowed.

.. code-block:: python

fields = [‘SET’, 1, 2, 3, 4, 5, 6, …, n]

pyNastran.bdf.field_writer_8.print_int_card_blocks(fields_blocks)[source]
Prints a nastran-style card with 8-character width fields. All fields other than the card name must be written in “block” format. This is used to speed up SET cards.
Parameters:
fields_blocks : List[int]

The fields written in “block” notation.

Returns:
msg : str

the field blocks as a 8-character width Nastran card

Note

Blanks are allowed in the False block.

fields_blocks = [
    'SET1',
    [['a', 1.0, 3], False], # these are not all integers
    [[1, 2, 3], True],      # these are all integers
]
msg = print_int_card_blocks(fields_blocks)
print(msg)
>>> 'SET1           a      1.       3       1       2       3
pyNastran.bdf.field_writer_8.print_scientific_8(value)[source]

Prints a value in 8-character scientific notation. This is a sub-method and shouldnt typically be called

Notes

print_float_8 : a better float printing method

pyNastran.bdf.field_writer_8.set_blank_if_default(value, default)[source]

Used when setting the output data of a card to clear default values

Parameters:
value : int/float/str

the field value the may be set to None (blank) if value=default, the default value for the field

default : int/float/str

the default value

.. note:: this method is used by almost every card when printing
pyNastran.bdf.field_writer_8.set_default_if_blank(value, default)[source]

Used when initializing a card and the default value isn’t set Used on PBARL

pyNastran.bdf.field_writer_8.set_string8_blank_if_default(value, default)[source]

helper method for writing BDFs

field_writer_16 Module

Defines functions for single precision 16 character field writing.

pyNastran.bdf.field_writer_16.print_card_16(fields, wipe_fields=True)[source]

Prints a nastran-style card with 16-character width fields.

Parameters:
fields : List[varies]

all the fields in the BDF card (no trailing Nones)

wipe_fields : bool; default=True

some cards (e.g. PBEAM) have ending fields that need to be there, others cannot have them.

Returns:
card : str

string representation of the card in small field format

Note

An internal field value of None or ‘’ will be treated as a blank field

Note

A large field format follows the 8-16-16-16-16-8 = 80 format where the first 8 is the card name or blank (continuation). The last 8-character field indicates an optional continuation, but because it’s a left-justified unneccessary field, print_card doesnt use it.

pyNastran.bdf.field_writer_16.print_field_16(value)[source]

Prints a 16-character width field

Parameters:
value : int / float / str / None

the value to print

Returns:
field : str

an 16-character string

pyNastran.bdf.field_writer_16.print_float_16(value)[source]

Prints a float in nastran 16-character width syntax using the highest precision possbile. .. seealso:: print_float_8

pyNastran.bdf.field_writer_16.print_scientific_16(value)[source]

Prints a value in 16-character scientific notation. This is a sub-method and shouldnt typically be called

See also

print_float_16 for a better method

pyNastran.bdf.field_writer_16.set_string16_blank_if_default(value, default)[source]

helper method for writing BDFs

field_writer_double Module

Defines functions for double precision 16 character field writing.

pyNastran.bdf.field_writer_double.print_card_double(fields, wipe_fields=True)[source]

Prints a nastran-style card with 16-character width fields.

Parameters:
fields : List[varies]

all the fields in the BDF card (no trailing Nones)

wipe_fields : bool; default=True

some cards (e.g. PBEAM) have ending fields that need to be there, others cannot have them.

Returns:
card : str

string representation of the card in small field format

Note

An internal field value of None or ‘’ will be treated as a blank field

Note

A large field format follows the 8-16-16-16-16-8 = 80 format where the first 8 is the card name or blank (continuation). The last 8-character field indicates an optional continuation, but because it’s a left-justified unneccessary field, print_card doesnt use it.

pyNastran.bdf.field_writer_double.print_field_double(value)[source]

Prints a 16-character width field

Parameters:value – the value to print
Returns field:an 16-character string
pyNastran.bdf.field_writer_double.print_scientific_double(value)[source]

Prints a value in 16-character scientific double precision.

Scientific Notation: 5.0E+1 Double Precision Scientific Notation: 5.0D+1