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:
fieldslist[int/float/str/None]

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

sizeint; default=8

the size of the field (8/16)

is_doublebool; 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:
cardstr

string representation of the card

Note

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

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

field_writer_8 Module

Defines functions for single precision 8 character field writing.

pyNastran.bdf.field_writer_8.is_same(value1: Any, value2: Any) bool[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: list[int | float | str | None]) str[source]

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

Parameters:
fieldslist[int/float/str/None]

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

Returns:
cardstr

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 unnecessary field, print_card doesn’t use it.

pyNastran.bdf.field_writer_8.print_field_8(value: int | float | str | None) str[source]

Prints a 8-character width field

Parameters:
valueint/float/str

the value to print

Returns:
fieldstr

an 8-character string

pyNastran.bdf.field_writer_8.print_float_8(value: float) str[source]

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

pyNastran.bdf.field_writer_8.print_int_card(fields: list[int | float | str | None]) str[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:
fieldslist[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] print_int_card(fields) >>> fields ‘SET1, 1, 2, 3, 4, 5, 6, …’ ‘ , n’

pyNastran.bdf.field_writer_8.print_int_card_blocks(fields_blocks: list[Any]) str[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_blockslist[int]

The fields written in “block” notation.

Returns:
msgstr

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: float) str[source]

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

Notes

print_float_8 : a better float printing method

pyNastran.bdf.field_writer_8.set_blank_if_default(value: Any, default: Any) int | float | str | None[source]

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

Parameters:
valueint/float/str

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

defaultint/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: Any, default: Any) int | float | str[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: Any, default: Any) str[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: list[int | float | str | None], wipe_fields: bool = True) str[source]

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

Parameters:
fieldslist[varies]

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

wipe_fieldsbool; default=True

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

Returns:
cardstr

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 unnecessary field, print_card doesn’t use it.

pyNastran.bdf.field_writer_16.print_field_16(value: int | float | str | None) str[source]

Prints a 16-character width field

Parameters:
valueint / float / str / None

the value to print

Returns:
fieldstr

an 16-character string

pyNastran.bdf.field_writer_16.print_float_16(value: float) str[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: float) str[source]

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

See also

print_float_16 for a better method

pyNastran.bdf.field_writer_16.set_string16_blank_if_default(value: Any, default: Any) str[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: list[int | float | str | None], wipe_fields: bool = True) str[source]

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

Parameters:
fieldslist[varies]

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

wipe_fieldsbool; default=True

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

Returns:
cardstr

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 unnecessary field, print_card doesn’t use it.

pyNastran.bdf.field_writer_double.print_field_double(value: int | float | str | None) str[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: float) str[source]

Prints a value in 16-character scientific double precision.

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