pw:: Script

Global actions for controlling script behavior

Derives From

pw::Object

Summary
Global actions for controlling script behavior
This attribute is a flag for whether the Glyph Server is actively listening for client connections or not.
This attribute is the TCP port number of that the Glyph Server listens on for client connections.
This attribute is an authentication code used to authenicate the clients that attempt to connect to the Glyph Server.
This attribute is a flag for whether clients on remote hosts will be allowed to connect to the Glyph Server.
This attribute is a flag for whether meshing on unstructured domains should be skipped.
This action processes incoming messages to the Glyph Server, which allows executing Glyph commands in Pointwise over a TCP port.
This action includes and executes the specified Glyph file with its own undo level.
This action loads and initializes the Tk library for use in the script.
This action creates a string that, when displayed in the Messages window, creates a link to a point or list of points.
This action creates a string that, when displayed in the Messages window, creates a link to a set of entities.
This action creates a string that, when displayed in the Messages window, creates a hyperlink to a file or directory.

Static Attributes

ServerActive

pw::Script get/setServerActive active

This attribute is a flag for whether the Glyph Server is actively listening for client connections or not.  Only client connections originating from the localhost will be responded to unless ServerAllowRemote is true.

Type

This attribute is a boolean value.

Default

The default for this attribute is true or the value of the PWI_GLYPH_SERVER_ACTIVE environment variable, if it set.

Information

If this attribute is set to true and the current ServerPort is already in use, an alternate port that is not currently in use will be used, and the ServerPort attribute will be updated.

Errors

This attribute cannot be set in non-interactive mode or through a Glyph Server connection.

ServerPort

pw::Script get/setServerPort port

This attribute is the TCP port number of that the Glyph Server listens on for client connections.  Only client connections originating from the localhost will be responded to unless ServerAllowRemote is true and ServerAuthentication is not an empty string.

Type

This attribute is an integer with the range [1025, 65536].

Default

The default for this attribute is 2807 or the value of the PWI_GLYPH_SERVER_PORT environment variable, if it is set.  However, if the default port is in use by another application, a random port number that is unused will be assigned.

Information

If this attribute is modified and the Glyph Server is currently active it will be deactivated temporarily, the port changed and reactived.  It is possible that errors will occur during this process leading to the Glyph Server becoming deactived.

Errors

This attribute cannot be set through a Glyph Server connection.

ServerAuthentication

pw::Script get/setServerAuthentication code

This attribute is an authentication code used to authenicate the clients that attempt to connect to the Glyph Server.

Type

This attribute is a string with maximum length of 40.

Default

The default for this attribute is an empty string or the value of the PWI_GLYPH_SERVER_AUTH environment variable, if it is set.

Errors

This attribute cannot be set through a Glyph Server connection.

ServerAllowRemote

pw::Script get/setServerAllowRemote allow

This attribute is a flag for whether clients on remote hosts will be allowed to connect to the Glyph Server.  In order for remote hosts to connect this attribute must be true and the ServerAuthentication attribute must be set to a non empty string.

Type

This attribute is a boolean.

Default

The default for this attribute is false.

Errors

This attribute cannot be set through a Glyph Server connection.

DomainUnstructuredSkipMeshing

pw::Script get/setDomainUnstructuredSkipMeshing skip

This attribute is a flag for whether meshing on unstructured domains should be skipped.  The attribute value will be reset to the default value after script execution.

Type

This attribute is a boolean.

Default

The default for this attribute is false.

Static Actions

processServerMessages

pw::Script processServerMessages ?-authentication code? ?-allowRemote allow? ?-timeout seconds?

This action processes incoming messages to the Glyph Server, which allows executing Glyph commands in Pointwise over a TCP port.

Parameters

-authentication codeThis optional parameter is the string authentication code that clients must use to communicate with the server.  The default is the current value of the ServerAuthentication parameter.
-allowRemote allowThis optional parameter is the boolean flag which sets whether a client from a remote host will be allowed to communicate with the server.  The default is the current value of the ServerAllowRemote parameter.  Even when set to true, an authentication code must be in use for remote hosts to connect to the server.
-timeout secondsThis optional parameter is the integer number of seconds to wait for a client connection.  The default is -1, which specifies that it will wait indefinitely.

Information

The Glyph Server protocol is a simple message based TCP protocol for executing glyph commands given by a client that connects to the Glyph Server.  Each message sent to or from the server consists of a 4 byte network ordered (big-endian) unsigned integer with the value representing the length of the following message in bytes.

Each message is further defined as starting with an 8 byte string denoting the type of message with spaces padding on the right, followed by a variable length string payload.

After a client connects, it should immediately send an authentication message:

  • type: AUTH, payload: the authentication string

After the AUTH message has been sent, the server will send one of three messages:

  • type: READY, payload: Empty
  • type: AUTHFAIL, payload: Empty
  • type: BUSY, payload: Empty
  • type: ERROR, payload: error description

The READY message signals to the client that messages will be accepted from the client by the server.  The AUTHFAIL message will be send if the client couldn’t not be authenticated.  The BUSY message will be sent when another client is currently connected to the Server or the Pointwise application is otherwise busy.  The ERROR message will be sent for any other issue not covered by the above cases for which an established connection did not occur.

After the READY message has been returned, the client may send one or more of the following messages:

  • type: CONTROL, payload: a control message
  • type: EVAL, payload: a Glyph command, including support for nested commands and variable substitution
  • type: COMMAND, payload: a JSON encoded array with the first element is a Glyph command and all other elements are parameters to the Glyph command
  • type: PING, payload: Empty

The CONTROL message is handled by the Glyph Server by modifying or querying a setting of the Glyph Server.  To modify a setting, the message should be in the form “setting=value”.  To query a setting, the message should be just the name of the setting.  After the message is received, the Glyph Server responds with one of two messages:

  • type: OK, payload: the current value of the setting
  • type: ERROR, payload: error description

Control settings include:

  • logrecv - boolean whether to log messages received
  • logsend - boolean whether to log messages sent

The EVAL message is handled by the Glyph Server by evaluating the Glyph command.  Once complete, the Glyph Server responds with one of two messages:

  • type: OK, payload: result of Glyph command
  • type: ERROR, payload: error description

The COMMAND message is handled by the Glyph Server by running the given Glyph command and parameters.  The command and parameters must be actual values since no nested commands or variable substitution will be evaluated.  Once completes, the Glyph Server responds with one of two messages:

  • type: OK, payload: JSON encoded result of Glyph command
  • type: ERROR, payload: error description

The Glyph Server supports JSON according to RFC 7159, which supports boolean, number and string values at the top level.  When a Glyph command returns a single value, it will be returned as a value at the top level of the JSON data.

The PING message is handled by the Glyph Server by simply returning an OK message.  This may be used to determine whether the client-server connection is still active.  After the message is received, the Glyph Server will respond with the following message:

  • type: OK, payload: OK message

Errors

This action cannot be run through a Glyph Server connection.

Returns

This action returns nothing.

source

pw::Script source filename

This action includes and executes the specified Glyph file with its own undo level.  If the Glyph file is a self-contained script and modifies the undo stack, using this method instead of the standard Tcl source command will contain the undo changes within the script.

Parameters

filenameThis parameter is the name of the Glyph file to include.

Returns

This action returns a boolean, which is true if the script executes successfully.

loadTk

pw::Script loadTk

This action loads and initializes the Tk library for use in the script.

Parameters

none

Returns

This action returns nothing.

createPointLink

pw::Script createPointLink ?-title string? link_text points

This action creates a string that, when displayed in the Messages window, creates a link to a point or list of points.  This only occurs when the command is run in interactive mode.  In batch mode, no links are created.  Instead, just a comma-separated list of the point values are generated.

Parameters

titleIf specified, this controls the tooltip text that is shown when the user hovers over the link.
link_textThis string specifies the text that serves as the link in the messages window.
pointThis argument is expected to be a list of one or more point values.

Returns

This action returns a string value that can be used with the puts Tcl command.

Example

This example shows how to create a link to an XYZ point.

Code

set cn(1) [create2PtConnector {0 0 0} {10 0 0} 21]
set n 15
set pt [$cn(1) getPoint $n]
set link [pw::Script createPointLink "point $n" $pt]
puts "Maximum located at $link."

Output

Maximum located at <a href='pwpnt://pwi.app?loc=7.5 0.0 0.0'>point 15</a>."

createEntityLink

pw::Script createEntityLink ?-title string? link_text entities

This action creates a string that, when displayed in the Messages window, creates a link to a set of entities.  This only occurs when the command is run in interactive mode.  In batch mode, no links are created.  Instead, the returned string value is a space-separate list of the entity function names.

Parameters

titleIf specified, this controls the tooltip text that is shown when the user hovers over the link.
link_textThis string specifies the text that serves as the link in the messages window.
entitiesThis argument is expected to be a list of one or more pw::Entity objects that can be selected in the display.

Returns

This action returns a string value that can be used with the puts Tcl command.

Example

This example shows how to create a link to a list of two entities.

Code

set cn(1) [create2PtConnector {0 0 0} {10 0 0} 21]
set cn(2) [create2PtConnector {0 5 0} {10 5 0} 21]
set link [pw::Script createEntityLink -title "New Connectors" "2 connectors" [list $cn(1) $cn(2)]]
puts "Created $link."

Output

Created <a href='pwent://pwi.app?ents=::pw::Connector_1 ::pw::Connector_2' title='New Connectors'>2 connectors</a>."

createFileLink

This action creates a string that, when displayed in the Messages window, creates a hyperlink to a file or directory.  This only occurs when the command is run in interactive mode.  In batch mode, no links are created.  Instead, just the file or directory name is returned.

Parameters

titleIf specified, this controls the tooltip text that is shown when the user hovers over the link.
link_textThis string specifies the text that serves as the link in the messages window.
pathThis argument is expected to be a string corresponding to a file or directory path.  A folder in the path can be a @FolderId token which will be expanded to the actual runtime value in the link.  Current tokens are: SysInstall, SysBin, SysCommon, SysDoc, SysLicense, SysAltLicense, SysUserPrivate, SysUserHome, SysUserPublic, SysAppPrivate, SysAppPublic, SysTemp, AppPrivate, AppPublic, AppPlugins, PrivatePlugins, PublicPlugins, and URLDocBase.  If the command is run in batch mode, then the path is returned as the result.  Any @FolderId tokens are expanded.

Returns

This action returns a string value that can be used with the puts Tcl command.

Example

This example shows how to create a link to a file.

Code

set file [file join @SysInstall doc PDF Glyph.pdf]
set link [pw::Script createFileLink "Glyph Docs" $file]
puts "For reference: $link."

Output

For reference: <a href='pwfile://@SysInstall/doc/PDF/Glyph.pdf'>Glyph Docs</a>."
pw::Script get/setServerActive active
This attribute is a flag for whether the Glyph Server is actively listening for client connections or not.
pw::Script get/setServerPort port
This attribute is the TCP port number of that the Glyph Server listens on for client connections.
pw::Script get/setServerAuthentication code
This attribute is an authentication code used to authenicate the clients that attempt to connect to the Glyph Server.
pw::Script get/setServerAllowRemote allow
This attribute is a flag for whether clients on remote hosts will be allowed to connect to the Glyph Server.
pw::Script get/setDomainUnstructuredSkipMeshing skip
This attribute is a flag for whether meshing on unstructured domains should be skipped.
pw::Script processServerMessages ?-authentication code? ?-allowRemote allow? ?-timeout seconds?
This action processes incoming messages to the Glyph Server, which allows executing Glyph commands in Pointwise over a TCP port.
pw::Script source filename
This action includes and executes the specified Glyph file with its own undo level.
pw::Script loadTk
This action loads and initializes the Tk library for use in the script.
pw::Script createPointLink ?-title string? link_text points
This action creates a string that, when displayed in the Messages window, creates a link to a point or list of points.
pw::Script createEntityLink ?-title string? link_text entities
This action creates a string that, when displayed in the Messages window, creates a link to a set of entities.
Base type for all glyph types
A boolean is represented as a 0 or 1, with 0 being false and 1 being true.
An integer is a whole number.
A string is an array of characters.
A point is a position either in model space or database parameter space.
Entity type