How do I get the element types/material types of all the elements a node is shared by using DPF?
Ayush Kumar
Member, Moderator, Employee Posts: 449
✭✭✭✭
How do I get the element types/material types of all the elements a node is shared by using DPF?
Tagged:
0
Best Answer
-
You can use the following code in Mechanical Scripting console, please change the
node_id
andGetDataSources
index accordingly.NOTE - Works only from 2022R1 onwards
import mech_dpf import Ans.DataProcessing as dpf mech_dpf.setExtAPI(ExtAPI) model = dpf.Model(mech_dpf.GetDataSources(1)) node_id = 1300 mesh = model.Mesh field_nodal = mesh.NodalConnectivityPropertyField element_indices = field_nodal.GetEntityDataById(node_id) element_scope = mesh.ElementScoping all_elements = [element_scope.IdByIndex(index) for index in element_indices] e_prop = mesh.GetPropertyField("apdl_element_type") e_types = [e_prop.GetEntityDataById(index)[0] for index in all_elements] mat_prop = mesh.GetPropertyField("mat") mat_ids = [mat_prop.GetEntityDataById(index)[0] for index in all_elements] print e_types print mat_ids
1