How to create a named selection of nodes which have equivalent stress above a certain limit?

Rohith Patchigolla
Member, Moderator, Employee Posts: 242
✭✭✭✭
in Structures
I have an equivalent stress result in Mechanical. I want to create a nodal named selection which has nodes corresponding to equivalent stress above a certain value
Tagged:
0
Best Answer
-
Here is a simple script (tested in 2021R2). Please try pasting this script in Mechanical Scripting Console after solving the model. This should create a new Nodal named selection with the corresponding nodes.
#Inputs #Stress Limit in MPa strLimitMPa = 10 #Use the name of the Equivalent Stress object in the tree (try to have a unique name for the result objects) stress_Object_Name = "Equivalent Stress 1" #Remainig Code strLimit = strLimitMPa*1e6 eqvStr = DataModel.GetObjectsByName(stress_Object_Name)[0] plt = eqvStr.PlotData scopedNodes = plt["Node"] scopedResults = plt["Values"] # Get indices of elements in scopedResults that are greater than certain stress value indices = [i for i, value in enumerate(scopedResults) if value > strLimit] # Filter scopedNodes list based on the indices filtered_scopedNodes = [scopedNodes[i] for i in indices] nodeSel = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.MeshNodes) nodeSel.Ids = filtered_scopedNodes NsObj = DataModel.GetObjectsByType(DataModelObjectCategory.NamedSelections) if len(NsObj) == 0: newNodalNS = Model.AddNamedSelection() else: newNodalNS = Model.NamedSelections.AddNamedSelection() newNodalNS.Location = nodeSel newNodalNS.Name = "NodesAboveLimit_" + str(strLimitMPa) + "_MPa_" + eqvStr.Name Tree.Refresh()
0
Answers
-
Also see this post which does a similar operation, but for total deformation: https://discuss.ansys.com/discussion/2431/filter-elements-with-deformation-above-a-value-and-change-their-material-properties
0