ansys.dyna.core.lib.keyword_base.KeywordBase#
- class ansys.dyna.core.lib.keyword_base.KeywordBase(**kwargs)#
Bases:
ansys.dyna.core.lib.cards.Cards,ansys.dyna.core.lib.option_card.OptionsInterfaceBase class for all keywords.
KeywordBaseis the sole owner of option activation state (_active_options). Card-set items that inherit fromCardsdelegate option queries back to the keyword through_keyword.- Derived class must provide::
_cards
keyword
subkeyword
- property deck: ansys.dyna.core.lib.deck.Deck | None#
Get the deck that this keyword is associated to.
- property format: ansys.dyna.core.lib.format_type.format_type#
Get or set the format for this keyword.
- get_option_spec(name: str) ansys.dyna.core.lib.option_card.OptionSpec#
Gets the option spec for the given name.
- property option_specs: Iterable[ansys.dyna.core.lib.option_card.OptionSpec]#
Gets all option specs by scanning the card list.
- property cards: List[ansys.dyna.core.lib.card_interface.CardInterface]#
Gets the cards of the keyword
- property included_from: str#
Get the filename this was included from.
If the keyword was not read from a file, return None.
- __repr__() str#
Returns a console-friendly representation of the keyword data as it would appear in the .k file
- write(buf: TextIO | None = None, format: ansys.dyna.core.lib.format_type.format_type | None = None, deck_format: ansys.dyna.core.lib.format_type.format_type = format_type.default, retain_parameters: bool = False) str#
Renders the keyword in the dyna keyword format.
- Parameters:
- buf: IO
Optional - buffer to write to.
- format: format_type, optional
Format to use for writing.
- deck_format: format_type, optional
The deck’s format (used to determine if format symbol needed).
- retain_parameters: bool, optional
If True, write original parameter references (e.g., &myvar) instead of substituted values for fields that were read from parameters. Default is False.
- Returns:
- read(buf: TextIO, parameters: ansys.dyna.core.lib.parameters.ParameterSet = None, import_context: ansys.dyna.core.lib.import_handler.ImportContext | None = None) None#
Read the keyword from a buffer.
- Parameters:
- buf
typing.TextIO Buffer to read from.
- parameters
ParameterSet,optional Parameter set for substitution.
- import_context
ImportContext,optional Import context with file path and line number for warnings/errors.
- buf
- loads(value: str, parameters: ansys.dyna.core.lib.parameters.ParameterSet = None, import_context: ansys.dyna.core.lib.import_handler.ImportContext | None = None) Any#
Load the keyword from string.
Return self to support chaining
- get_links(link_type: LinkType = None, level: int = 1, _seen: Set | None = None) List[KeywordBase]#
Get all keywords referenced by this keyword.
Traverses the fields of this keyword that reference other keywords and returns the linked keyword objects from the parent deck.
- Parameters:
- link_type
LinkType,optional Filter results by link type. If
NoneorLinkType.ALL, returns all linked keywords. Otherwise, returns only keywords matching the specified link type.- level
int, default=1 Traversal depth.
1returns only direct links (default),-1traverses recursively without limit,0returns empty list, and any positive integerntraverses up tonlevels deep.- _seen
set,optional Internal parameter for cycle prevention. Do not pass explicitly.
- link_type
- Returns:
List[KeywordBase]List of referenced keyword objects. Returns an empty list if the keyword is not associated with a deck or if no links are found.
Examples
>>> mat = deck.keywords[0] # A material keyword with curve references >>> curves = mat.get_links(LinkType.DEFINE_CURVE) >>> all_links = mat.get_links() # Get all referenced keywords >>> # Get full dependency tree >>> all_deps = mat.get_links(level=-1)