Tcl/Tk Commands

The HyperWorks Desktop scripting interface is a set of Tcl/Tk commands that follow a simple and consistent syntax.

All commands are object-centric, which means that you must have an object to which a command can be applied. The basic command syntax is:

{object_handle_name} {command}{command parameter(s) }

Tcl/Tk Command Categories

The HyperWorks Tcl/Tk commands fall into different categories that manipulate the HyperWorks database.

Handle Commands

Handle commands obtain access to other objects. Handle commands have a "Get" prefix and a "Handle" suffix.

For example:
  • Tcl> hwi GetSessionHandle sess1
  • Tcl> sess1 GetProjectHandle proj1
Command Parameters
The first argument is always a handle name used to reference the desired object. Additional arguments are possible.
Return Value
The handle name if successful or an error code if the command fails.

Operation Commands

Operation commands perform an operation or task.

For example:
  • Tcl> sess1 CaptureScreen "jpeg" "myimage jpg"
  • Tcl> post1 AddMode1
Command Parameters
Command dependent.
Return Value
"0" if successful or an error code if the command fails.

Property Commands Query Options

Property Commands Query operations prefixed by "Get"return the internal state of an object. Mutate operations prefixed by "Set" modify the internal state of an object.

For example:
  • Tcl> page1 GetTitle
  • Tcl> page1 SetTitle "My Page"
Get:
Command Parameters
Command dependent.
Return Value
State value.
Set:
Command Parameters
State value.
Return Value
"0" if successful or an error code if the command fails.

List Commands

List Commands return a list of values. List commands have a "Get" prefix and a "List" suffix.

For example:
  • Tcl> post1 GetModelList

Object Hierarchy

The HyperWorks database consists of a hierarchy of objects.

The root object of the HyperWorks database is the hwi object which is automatically created. The hwi provides access to the hwISession object and a few high level utilities. Currently, HyperWorks supports only one session per run. The session object can be retrieved by issuing the following command:

Tcl> hwi GetSessionHandle sess1

Once the session handle is retrieved, it can be used to access all objects in the HyperWorks database as shown in Figure 1.


Figure 1.
Windows are retrieved and assigned a client type, which can be modified.
  • Tcl> page1 GetWindowHandle win1 1
  • Tcl> win1 SetClientType "Animation"
  • Tcl> win1 GetClientHandle post1

A window's client type cannot be changed after the client handle has been retrieved. The client handle must be released and retrieved again if the window's client type is changed.

Every HyperWorks's command object supports the following utility commands:
ListMethods
Displays the method commands which can be performed on an object.
ListHandles
Lists the names of all command objects of the same type.
ReleaseHandle
Releases the command object
The top level hwi command object supports the following utility commands:
ListAllHandles
Displays all command objects currently in use.
OpenStack
Begins automatic handle tracking.
CloseStack
Ends automatic handle tracking and releases any handles acquired during handle tracking.