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.
- 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.
- 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.
- Tcl> page1 GetTitle
- Tcl> page1 SetTitle "My Page"
- Command Parameters
- Command dependent.
- Return Value
- State value.
- 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.
- Tcl> post1 GetModelList
Object Hierarchy
The HyperWorks database consists of a hierarchy of objects.
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.- 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.
- 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
- 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.