You are on page 1of 3

Hmath Tutorial: Debugging TCL script using ScriptView

TCL macros written for HyperWorks can be debugged using ScriptView. This eliminates the
requirement of using print statements to guess location where the macro failed to work. The
two requirements to debug the TCL script in ScriptView are: 1) User needs to use
HyperMesh Desktop 2) The TCL macro must be contained in a procedure.
This tutorial demonstrates the way to link HyperWorks Desktop with ScriptView for live
debugging. The TCL Script used in this tutorial allows the user to select a single circle and
outputs the radius and the diameter of the circle. As the TCL script is debugged, it highlights
the usage of “watch window”, breakpoints etc.

Step 1: Launch HyperMesh Desktop


1. Launch HyperMesh Desktop
2. Under the File Menu, select Open > Model and select TCL_debug.hm.
3. Click Open
4. Under the View Menu, select Toolbars > HyperWorks > Scripting
5. Notice that a new tool set of icons in the toolbar

Step 2: Launch and execute TCL script


Before the TCL script is debugged, we shall execute the script to show the process and
output of the script.
1. Select the fourth icon, Run Tcl/Tk script, on the scripting toolbar shown above.
2. In the new window dialog, select radius.tcl.
3. Select exactly one circle in the model.
4. Click proceed.
5. A new dialog appears with the results of the Diameter and Radius of the circle.

6. Click OK on the dialog above to stop the execution of the macro.

Step 3: Debug the Script


1. Click on the third icon, Debug Tcl/Tk Script, in the scripting toolbar.
2. In the new window dialog, select radius.tcl.
3. Click Open.

1
4. Notice that ScriptView is launched with radius.tcl file already loaded in the editor
window
5. Notice that a blue triangle appears in line 38 indicating that the procedure
::madapadi_051909::main is being evaluated
6. Click to add breakpoints (shown as circles) on lines 16, 24 and 29

7. Click on the second icon to start the debug

8. The control is now transferred to HyperMesh Desktop. Click on any one circumference
of a hole in the model and then click proceed
9. The control is now transferred to ScriptView, notice the program is highlighted in the
windows bar.
10. The blue arrow is now located at line 16; which is the location of the first breakpoint.
11. Click on the third icon (Step Over) as shown in Step 7 to move the blue arrow to line 18.
Move the cursor on top of variable “c” in line 16 to see the value of that variable as shown
in the picture below.

2
12. Click on the second icon in Step 7 (Continue) to proceed to the second breakpoint at
line 24.
13. Click on the third icon in Step 7 (Step Over) to proceed to the line 25.
14. Move the cursor over the variable d_x to find its value
15. Click the second icon in Step 7(Continue) to proceed to line 30 and move the cursor
over the variable diameter to find it’s value.
16. Click the second icon in Step 7(Continue) to complete the execution of the macro and
the following dialog appears.

17. Click OK on the dialog.


18. In ScriptView, select File > Exit to close the program.

You might also like