Ansys mechanical scripting. How to get Element type ID's using mechanical scripting?
This figure is taken from the worksheet tab. I'm trying to use mechanical scripting to get the element type ids for element names I'm interested in. For example, if im interested in SOLID 187, I'd like to get the element type ID's for all solid187 using mechanical scripting.
Best Answers
-
@atb5dc This could be slow as we are looping over all the elements, but it should give you what you want.
analysis = ExtAPI.DataModel.AnalysisList[0] resultReader = analysis.GetResultsData() meshData = resultReader.CreateMeshData() ename_to_etype_dict = {} etype_num_list = [] for element_id in meshData.ElementIds: bool_flag, e_type_num = resultReader.GetElemType(element_id) if not e_type_num in etype_num_list: etype_num_list.append(e_type_num) _, _, _, _, ename = resultReader.GetElemTypeProps(e_type_num) if ename in ename_to_etype_dict.keys(): ename_to_etype_dict[ename].append(e_type_num) else: ename_to_etype_dict[ename] = [e_type_num] print(ename_to_etype_dict)
0 -
@atb5dc ,
You may also want to be aware of the SolverData data type that can be accessed from the Solution objects. This stores APDL Id data for most objects in the tree that produce it. For example you can point to a contact and get the contact and target Ids that were used in the input file for that contact.
See this post as an example for getting information about a pressure that has surface elements with their own Id types as an example of a load. Joints, Bearings, Bodies, Springs, Remote points, Coord Syst. etc…. All of these have Id data that can be accessed via this data model type and does not need to ping the solution file.5
Answers
-
awesome. thank you so much
0 -
Is it possible to extract Element Type ID of a body during the solution via Python Code object?
0 -
Yes. In the python code there is a solver_data object that has a method to get a type for a given body. This object is described in the default header.
0