General Mechanical

General Mechanical

Topics related to Mechanical Enterprise, Motion, Additive Print and more.

How can I count nodes above a threshold value?

    • RustyJohnston
      Subscriber

      I am working on a model and I want to count the number of nodes that are above or below a threshold value. I imagine this could be done somehow with scripting, but I don't know enough about that in ANSYS to do it on my own. I am sure that ansys already does something like this to make contour bands. Thanks in advance.

    • Erik Kostson
      Ansys Employee

      If we say have a displacement results and do export, we can filter in excel and se how many nodes there are.

      Otherwise of course this is scriptable either with mechanical act, or with apdl command object .

      As an example (for UZ displacement) the sample code below gets nodes that have absolute z-displacements larger than 0.009 m. These nodes are also added to a named selection and finally a result is scoped to these nodes only.

      model=ExtAPI.DataModel.Project.Model # refer to model

      reader = model.Analyses[0].GetResultsData() # get results data of first analysis in the tree

      DispResults = reader.GetResult('U') # obtain stress results

      DispResults.SelectComponents(["Z"]) # select direction

      nd=ExtAPI.DataModel.Project.Model.Mesh.Nodes

      stNdres=[]

      stNd=[]

      for i in range(1,nd):

      tempres=DispResults.GetNodeValues(i)

      if abs(tempres[0])>0.0090:

      stNdres.append(abs(tempres[0]))

      stNd.append(i)

      reader.Dispose
      temp_sel=ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.MeshNodes)

      nodeNs=ExtAPI.DataModel.Project.Model.AddNamedSelection temp_sel.Ids=stNd
      nodeNs.Location=temp_sel

      totDef=ExtAPI.DataModel.Project.Model.Analyses[0].Solution.AddTotalDeformation totDef.ScopingMethod=GeometryDefineByType.Component
      totDef.Location=temp_sel
      totDef.EvaluateAllResults
      All the best


    • RustyJohnston
      Subscriber
      Appreciate the info. While this answers my question in general, it would have been helpful if the example was specific to what I was asking so that I could use it/experiment with it directly, rather than having to do a bunch of additional research to figure out the missing pieces to get to what I needed. Still, this is much further than I was before.
Viewing 2 reply threads
  • The topic ‘How can I count nodes above a threshold value?’ is closed to new replies.