General Mechanical

General Mechanical

Inspecting Mesh Metrics in python

    • Jason Newton

      I'd like to learn how to access the mesh metrics value arrays in python , also getting topology arrays such as vertex values and/or indices.  There seems to be a lot of capability of interacting with the mesher's entities but I wasn't able to figure out where the data I would like to inspect lived.


      When using the macro recorder I did notice with making selections that face IDs or edge IDs would be populated to supply to the selection APIs but I couldn't figure out any way to inspect the faces in other ways, say by visiting topology related arrays.

    • Erik Kostson
      Ansys Employee





      One can get and set the meshmetric (mesh) in the Mechanical UI.

      To set the aspectratio:




      To get the maximum aspect ratio given in the mesh metric details in the UI:




      Hope this is of help




    • Erik Kostson
      Ansys Employee

      Actually a faster way is to get these direct in the geometry tree:


      geometry = ExtAPI.DataModel.Project.Model.Geometry

      bodies = geometry.GetChildren(DataModelObjectCategory.Body, True)

      for body in bodies:
          name = body.Name
          print(str(name)+"; ")
          print(str(body.Minimum)+"; ")
          print(str(body.Maximum)+"; ")
          print(str(body.Average)+"; ")


    • Jason Newton

      Is there any way to make a selection of meshed faces that have scores <= some threshold?  I can see from the histogram panel for mesh metrics that if I click on it I get neighborhoods of the geometry where meshing did poorly and needs investigation.  I'm opened to non python routes for that.  Most typically it seems applying some sizing controls to these selected neighborhoods works pretty well and is part of my immediate goals to more or less capture that process in a script.


      Baking up a step - is there any way to get the list of vertices, edges, and faces in python?

Viewing 3 reply threads
  • You must be logged in to reply to this topic.