- Python 3.7+
- Provided with pip requirements list
usage: k_parser.py [-h] -f FILEPATHS [FILEPATHS ...]
optional arguments:
-h, --help show this help message and exit
-f FILEPATHS [FILEPATHS ...], --filepaths FILEPATHS [FILEPATHS ...]
Input k files' ABSOLUTE filepaths
Example for two k_files:
% python3 k_parser.py -f /Users/danieljiang/Documents/UMTRI/UMTRI_M50/UMTRI_HBM_M50_V1.2_Nodes.k /Users/danieljiang/Documents/UMTRI/UMTRI_M50/UMTRI_HBM_M50_V1.2_Mesh_Components.k
References:
-
https://supunsetunga.medium.com/writing-a-parser-getting-started-44ba70bb6cc9
-
Part
- Element_Shell
- Node
- Element_Shell
def getNode(self, nid: int) -> Tuple[float]
Returns (x,y,z)
def getNodes(self, nids: list[int]=[]) -> list[Tuple[float]]:
Returns a list of coordinants
Example:
k_parser.getNodes([100000,100001])
returns all nodes
Example:
def getElementShell(self, eid: int, outputType: int=0) -> Union[list[Tuple[float]], list[int]]:
''' Return the ELEMENT_SHELL given its ID
Use outputType as:
0 = list of coordinantes of the corresponding nodes
1 = indices of the cooresponding nodes in self.nodes (better compatibility with vedo's
mesh constructor)
'''
Returns the ELEMENT_SHELL with different format options
Example:
k_parser.getElementShell(100005)
def getPart(self, pid: int, outputType: int=0) -> Union[list[list[Tuple[float]]], list[list[int]]]:
''' Return the PART given its ID
Use outputType as:
0 = list of list of coordinantes of the corresponding element shells.
e.g. [[(x1,y1,z1),(x2,y2,z2),(x3,y3,z3)],[(x4,y4,z4)]] where p1,p2,p3 compose
ELEMENT_SHELL1 and p4 composes ELEMENT_SHELL2
1 = indices of the cooresponding nodes in self.nodes (better compatibility with vedo's
mesh constructor)
e.g. [[n1_ind,n2_ind,n3_ind],[n4_ind]]
'''
Returns the part with different format options
Example:
k_parser.getPart(10003)
Get all parts