ansys.dyna.core.lib.field_schema.FieldSchema#

class ansys.dyna.core.lib.field_schema.FieldSchema#

Bases: NamedTuple

Immutable schema for a single field in a Card.

This is designed to be shared across all instances of a Card type. The default can be a value or a Flag instance for flag fields.

Attributes:
namestr

The lookup key used for get_value/set_value and kwargs matching. This should be the Python property name (e.g., “w_mode”).

typeType

The field type (int, float, str, bool).

offsetint

Column position in the card.

widthint

Column width.

defaultAny

Default value, or a Flag instance for flag fields.

display_namestr, optional

The original field name for display in comments (e.g., “w-mode”). If not provided, uses name.

name: str#
type: Type#
offset: int#
width: int#
default: Any = None#
display_name: str = ''#
get_display_name() str#

Get the display name for comments.

is_flag() bool#

Check if this field is a Flag type.

to_field(value: Any = None) ansys.dyna.core.lib.field.Field#

Create a Field instance from this schema with the given value.

Parameters:
valueAny, optional

The value to set. If None, uses the default.

Returns:
Field

A new Field instance.

classmethod from_field(field: ansys.dyna.core.lib.field.Field) FieldSchema#

Create a FieldSchema from an existing Field.

Parameters:
fieldField

The field to extract schema from.

Returns:
FieldSchema

An immutable schema representation.