### 2.7.2. Scripting

Scripting refers to the processes of editing and running a journal file in ANSYS Workbench. You can create your own scripts and include the power of the Python programming language to implement high-level programming constructs for input, output, variables, and logic.

Full support for scripting is available for ANSYS TurboGrid. Scripting is not available for BladeGen.

#### 2.7.2.1. Example: Using a Script to Change the Mesh Density in ANSYS TurboGrid

This example illustrates how a script can request and use user input. In this case, the mesh density is controlled based on user input:

    system1 = GetSystem(Name="TS")

    x = int(raw_input("Enter: 1=Medium-density mesh, 2=High-density mesh: "))

    if x == 1:
       print 'Medium-density mesh'
       turboMesh1 = system1.GetContainer(ComponentName="Turbo Mesh")
       turboMesh1.Edit()
       turboMesh1.SendCommand(Command=r"""MESH DATA:
          Target Mesh Granularity = Medium
          END""")
       turboMesh1.SendCommand(Command=r"""> mesh""")
       turboMesh1.Exit()
    elif x == 2:
       print 'High-density mesh'
       turboMesh1 = system1.GetContainer(ComponentName="Turbo Mesh")
       turboMesh1.Edit()
       turboMesh1.SendCommand(Command=r"""MESH DATA:
          Target Mesh Granularity = Fine
          END""")
       turboMesh1.SendCommand(Command=r"""> mesh""")
       turboMesh1.Exit()

The script includes the CCL in the appropriate `CFX.SendCommand` argument to set the `Target Mesh Granularity` option in the `MESH DATA` object for either a medium-density mesh or a fine mesh.

Before running this script, you would have to first open the Command Window dialog box (by selecting File > Scripting > Open Command Window from the ANSYS Workbench main menu), and you would have to have a TurboGrid system present, with ANSYS TurboGrid having a geometry already loaded and an unsuspended `Topology Set` object with suitable settings. To run the script, you would select File > Scripting > Run Script File from the ANSYS Workbench main menu and then use the browser to open the file containing the script. When the script is running, you define the value of x at the prompt in the Command Window dialog box.

Release 18.2 - © ANSYS, Inc. All rights reserved.