Using ACT, how can I create a result plot scoped to a path and a specific body?

Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 871
100 Answers 500 Comments 250 Likes First Anniversary
✭✭✭✭
edited June 2023 in Structures

Using ACT, how can I create a result plot scoped to a path and a specific body ?

Tagged:

Answers

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 871
    100 Answers 500 Comments 250 Likes First Anniversary
    ✭✭✭✭
    Answer ✓

    The following code will create a maximum principal stress plot scoped to a path named "my_path" and to a body named "my_body":

        solu=ExtAPI.DataModel.Project.Model.Analyses[0].Solution # refer to solution
        my_stress_path=solu.AddMaximumPrincipalStress() # add maximum principal stress plot
        path=ExtAPI.DataModel.GetObjectsByName("my_path")[0] # obtain reference to path by name
    
        # obtain reference to body thanks to its display name 
        geo = ExtAPI.DataModel.GeoData
        for asm in geo.Assemblies:
            for part in asm.Parts:
                for body in part.Bodies: 
                    if body.Name=="my_body":
                        my_body=body
                        
        # create temporary list of Ids for the body               
        temp_sel=ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
        temp_list=[my_body.Id]
        temp_sel.Ids=temp_list
    
        # modify result to define location (path and bodies)
        my_stress_path.Location = Ansys.Mechanical.Selection.PathLocation(path, temp_sel) # define location to selected path and bodies