Retrieve parameters and values

Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 873
100 Answers 500 Comments 250 Likes Second Anniversary
✭✭✭✭
edited November 2023 in Structures

Is it possible to retrieve information on the parameters defined in the Parameter Set of a WB project schematic?

Tagged:

Answers

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 873
    100 Answers 500 Comments 250 Likes Second Anniversary
    ✭✭✭✭
    edited November 2023

    This script will work from the WB project schematic.

    parameter_list = Parameters.GetAllParameters() # retrieve all parameters
    input_parameter_list = [item for item in parameter_list if item.Usage =='Input'] # work only with input parameters
    for index,value in enumerate(input_parameter_list):
        try:
            print(input_parameter_list[index].Name)
            print(input_parameter_list[index].DisplayText)
            print(input_parameter_list[index].Expression)
            print(input_parameter_list[index].Value.Value)
            print(input_parameter_list[index].Value.Unit)
        except:
            print(input_parameter_list[index].Name)
            print(input_parameter_list[index].DisplayText)
            print(input_parameter_list[index].Expression)
            print(input_parameter_list[index].Value)
            print('NA')
    
  • EhsanBa
    EhsanBa Member Posts: 18
    Name Dropper First Comment
    **

    @Pernelle Marone-Hitz
    Hi, I'm a newbie to WB scripting. I want to write a simple conditional algorithm based on an output parameter from FLUENT:

    The code must show a message based on the value of this single parameter. At first, I've written a simple code like:

    for parameter in Parameters.GetAllParameters():
        print parameter.DisplayText
        if parameter.DisplayText == 'flow-time-op':
            flowtime= parameter
    

    Is this correct?

    Also, I have no idea where the result of the "print" command goes inside the WB.

    Afterward, I want to show a message box based on the value. I've written this code to this end:

    import clr
    clr.AddReference('System.Windows.Forms')
    from System.Windows.Forms import Application, Form, Label
    form = Form(Text="End of Simulation")
    label = Label(Text="End.")
    label2 = Label(Text="Not Ended.")
    
    
    if (flowtime>40.0):
        form.Controls.Add(label)
    else:
        form.Controls.Add(label2)
    
    Form.ShowDialog(form)
    

    But, when I run this code, it always considers the value of this parameter equal to zero. ( the "else" condition will be shown). I have no idea what the problem is.

    Any help would be greatly appreciated.