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

Options
Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 831
First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
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: 831
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
    Answer ✓
    Options

    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