General Mechanical

General Mechanical

Access and Extract data from Selection Information Tab using Iron Python Script

    • akash.purushothaman
      Subscriber

      Whenever an entity is selected in Ansys Mechanical, it's information is shown in the Selection Information Tab.

      I would like to know how to access the Selection Information tab using Iron Python, so I would like to extract data from the table or can export the data to a text file.

      Thanks

    • Erik Kostson
      Ansys Employee

       

       

       

       

       

      Hi

       

      Selection Information data can not be accessed via act scripting.

      The best way to do this, is to do/run as follows (once a face is selected run script – script can be changed to look on body or edge information)

      face_sel = ExtAPI.SelectionManager.CurrentSelection
      faceIds=[]
      geometry = ExtAPI.DataModel.GeoData
      assemblies = geometry.Assemblies
      for assembly in assemblies:
              assembly_name = assembly.Name
              parts = assembly.Parts
              parts_count = parts.Count
              for part in parts:
                  part_name = part.Name
                  bodies = part.Bodies
                  bodies_count = bodies.Count
                  for body in bodies:
                      faces = body.Faces
                      faces_count = faces.Count
                      for face in faces:
                          fid=face.Id
                          try:
                              if fid == face_sel.Ids[0]:
                                  print(“exist : face ” + str(fid))
                                  faceIds.append(fid)
                                  print(face.Area)
                                  print(“X: ” + str(face.Centroid[0]))
                                  print(“Y: ” + str(face.Centroid[1]))
                                  print(“Z: ” + str(face.Centroid[2]))
                                  print(body.Name)
                                  print(face.SurfaceType)
                                  print(face.Id)
                          except:
                              print(“Select a face!”)

       

       

       

       

      • akash.purushothaman
        Subscriber

        Hi,

        But I am looking for a method to access the data in the table shown below. 

        This tab of Selection Information is activated when an entity is selected.

        In manual process, we select the required nodes and in the Selection Information Tab, we change the coordinate system to get the transformed coordinates to a different system.

        I am trying to achieve the same through ACT

Viewing 1 reply thread
  • You must be logged in to reply to this topic.