Rename reaction forces base on definition

Options
LBACHELOT
LBACHELOT Member Posts: 1
edited September 2023 in Structures

Hello everyone,

I encounter a problem while creating a script to extract the Force reactions Fx, Fy and Fz at all boundary conditions. The thing I want to do is to extract them and then rename them base on their definitions to be able to quickly see which reaction forces correspond to which boundary conditions. Therefore, I have started this script in python:

ma_liste=Model.GetChildren(DataModelObjectCategory.FixedSupport,True)
ma_liste2=Model.GetChildren(DataModelObjectCategory.Displacement,True)
ma_liste3=Model.GetChildren(DataModelObjectCategory.Spring,True)
solution=Model.Analyses[0].Solution

for fixedsupport in ma_liste:
    print(fixedsupport.Name)
    Fr=solution.AddForceReaction()
    Fr.LocationMethod=LocationDefinitionMethod.BoundaryCondition
    Fr.BoundaryConditionSelection=fixedsupport
    Fr.Name=Fr.RenameBasedOnDefinition()

for displacement in ma_liste2:
    print(displacement.Name)
    Fr2=solution.AddForceReaction()
    Fr2.LocationMethod=LocationDefinitionMethod.BoundaryCondition
    Fr2.BoundaryConditionSelection=displacement
    Fr2.Name=Fr2.RenameBasedOnDefinition()

for spring in ma_liste3:
    print(spring.Name)
    Fr3=solution.AddForceReaction()
    Fr3.LocationMethod=LocationDefinitionMethod.Spring
    Fr3.Spring=spring
    Fr3.Name=Fr3.RenameBasedOnDefinition()

solution.EvaluateAllResults()

But then when I run the script it is starting to create and rename but then shut down my ANSYS Mechanical window showing me an error message ...

Does anyone have an idea of why it is doing this ? (I am using V2022R2)

Comments

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee Posts: 208
    First Answer First Comment 5 Likes First Anniversary
    Options

    You need to remove Fr*.Name= from the start of the last line of each for loop:

    for fixedsupport in ma_liste:
        print(fixedsupport.Name)
        Fr=solution.AddForceReaction()
        Fr.LocationMethod=LocationDefinitionMethod.BoundaryCondition
        Fr.BoundaryConditionSelection=fixedsupport
        Fr.RenameBasedOnDefinition()