Trying to automate some results extraction and I haven't quite figured out how to tell if the location/scope of the result, when it is a name selection, is nodes or a geometry/body.
Hi, maybe you can try something like this? This script assumes that all the Named Selections have unique names.
# Get the result of interest sol = Model.Analyses[0].Children[3] tot_def = sol.Children[1] # Get the 'name' of the Named Selection to which the result is scoped tot_def_DetView = tot_def.GetDetailsView() tot_def_Scope = tot_def_DetView.data[2].value # Get the total number of Named Selections in the model NS = Model.NamedSelections tot_NS = len(Model.NamedSelections.Children) # Loop over all the Named Selections for i in range(tot_NS): NS1 = NS.Children[i] if NS1.Name == tot_def_Scope: # if the 'name' of the i-th Named Selection matches the 'name' of t the Named Selection to which result is scoped DetView = NS1.GetDetailsView() NS1_Type = DetView.data[2].value # Check if the Named Selection is scoped to 'Nodes' or 'Node' if NS1_Type[-5:] == 'Nodes' or NS1_Type[-4:] == 'Node': print "It is a Nodal Named Selection" else: print "It is NOT a Nodal Named Selection"
@said Thanks! that is what I needed. I shortened it a bit and just loop through the named selections to generate the list of named selections Ids that have 'node' in the detail.
nodal_ns_ids = [] for ns in ExtAPI.DataModel.GetObjectsByType(DataModelObjectCategory.NamedSelection): dv = ns.GetDetailsView() stype = dv.data[2].value if 'node' in stype.ToString().lower(): nodal_ns_ids.append(ns.Id)
@M that's a helpful tip. Thanks!
FYI, this is a more stable way to figure out if a NS is nodal or not:
NS.Location.SelectionType==Ansys.ACT.Interfaces.Common.SelectionTypeEnum.MeshNodes