PartKeyword¶
This class is used to manage parts of the KeyFile.
-
class
qd.cae.dyna.
PartKeyword
¶ - Attributes
field_size
field_size
position
Notes —– Line index of the
Keyword
.
Methods
add_part
(id[, name, additional_card_data])- Parameters
align
Type of alignment for comment names and fields:
append_line
(line)- Parameters
get_card_valueByIndex
(iCard, iField[, …])- Parameters
get_card_valueByName
(name[, field_size])- Parameters
get_keyword_name
()- Returns
get_line
()- Parameters
get_lines
()- Returns
- Returns
- Returns
has_long_fields
()- Returns
insert_line
(iLine, line)- Parameters
load
()Notes
reformat_all
([skip_cards])- Parameters
reformat_field
(iCard, iField[, field_size, …])- Parameters
remove_line
(iLine)- Parameters
set_card_valueByDict
(fields[, field_size])- Parameters
set_card_valueByIndex
(iCard, iField, value)- Parameters
set_card_valueByName
(name, value[, field_size])- Parameters
set_line
(iLine, line)- Parameters
set_lines
(lines)- Parameters
switch_field_size
([skip_cards])- Parameters
-
add_part
(id, name="", additional_card_data="")¶ - Parameters
- idint
id of the part
- namestr
name of the part
- additional_card_datastr or list of str
further card data (see Notes section).
- Returns
- partPart
newly created part object
- Raises
- ValueError
if id does already exist in the database
Notes
The
additional_card_data
is a string or a list of strings appended to the keyword when writing the output file. The first line or string is appended without a linebreak.Examples
>>> # create file with mesh parsing on >>> kf = KeyFile(parse_mesh=True) >>> # create a new part keyword >>> kw = kf.add_keyword("*PART") >>> # secid and mid for part >>> additional_data = " 2000001 2000017" >>> part = kw.add_part(100, "my_part", additional_data)
-
get_nParts
()¶ - Returns
- nPartsint
number of parts in the PartKeyword
Notes
Returns the parsed/loaded number of parts belonging to this keyword.
Examples
>>> # open file with mesh parsing on >>> kf = KeyFile("path/to/keyfile", parse_mesh=True) >>> kw = kf["*PART"][0] >>> kw.get_nParts() 1
-
get_parts
()¶ - Returns
- partslist of Part
list of all parts in the keyword
Notes
Yes, there can be more than one part in a part keyword.
Examples
>>> # open file with mesh parsing on >>> kf = KeyFile("path/to/keyfile", parse_mesh=True) >>> kw = kf["*PART"][0] >>> len( kw.get_parts() ) 1
-
load
()¶ Notes
This function iterates through the lines of the keyword, parses each part and loads it the files database. In the process, the lines of every parsed part is destroyed.
Examples
>>> kf = KeyFile(parse_mesh=True) >>> kw = kf.add_keyword("*PART") >>> kw.get_nParts() 0 >>> # append a new part (pid=2, secid=1, mid=1) >>> kw.append_line(" 2 1 1") >>> kw.load() >>> kw.get_nParts() 1 >>> print(kw) *PART 2 1 1