To refer to connection regions:
change the connection-region stripe-color of connection-class-name
to {color-name | symbolic-expression}
![]() |
Creating Transient Connections
Connections can be of any connection class and may be orthogonal or diagonal, with or without direction, and located at an existing stub or in an entirely new position. G2 creates stubs for connections newly locating it at some location on an object; otherwise, G2 requires that a stub already exist at the specified position (locating it at).with portname none. You can create a connection on one object (connected to) with the other end of the connection left free, or between two objects (connected between). The create action fails if one or both objects has a configuration statement specifying not manual-connections.
To create a connection using the create action:
create a connection [local name] [of {class connection-class-name |
the class named by symbolic-expression} ] connected
{between-spec | to-spec} connection-spec [, ...]
{between item from-position and item to-position |
to end-position}
| Element | Description |
|---|---|
from-position
|
The item from which the connection is being drawn.
|
to-position
|
The item to which the connection is connecting.
|
end-position
|
See the following syntax description.
|
{ [atport-name] [ [newly] locating it atside-expression
{ {left | top | right | bottom} | the side named by} } {integer |quantity-expression
at the position given by} [at {port-name|port-name-expression
the port named by} ] ]
{with style {diagonal | orthogonal} |symbolic-expression
with the style named by| with verticesinteger [,...]|integer-g2-list
with the vertices given by|direction-expression
with direction {input | output} |
with the direction named by|port-name
with portname}
![]() |
The next sections illustrate several ways of creating connections and explain the statements.
Creating a Connection on One Side of an Object
This action creates a transient system-defined connection on the right side of the D1 object.
![]() |
Note: To create a connection without direction, omit the with direction statement completely, as in this example. You cannot use the statement with direction none.
The newly locating it at statement indicates that no stub currently exists at the given location. If you omit this statement in any create action by stating only the position (at right 15), G2 requires that a stub exist at the location you specify. Creating a Directional Connection
This action connects two objects with a transient connection located at existing stub locations of both items:
![]() |
In this case, the statement also specifies a user-defined connection class,
km-connection, to use and a direction (input). Creating a Connection with Vertices
This action creates a connection, with specific vertices, on one side of an object, D1, as the example illustrates.
![]() |
Specifying Connection Vertices
You specify vertices (bends) for a connection with a list of numbers, which determine how G2 draws the segments and vertices of a connection. Separate vertex numbers with a space character, not a comma (,). top, bottom, right, or left). Positive numbers extend upwards and to the right of an icon, negative number extend downwards or to the left. The second number in a vertex specification determines in which direction the connection continues. After the second vertex, the pairs of values determine how G2 draws the remaining segments and vertices of the connection.
![]() |
Recreating an Existing Connection Programmatically
A common requirement in KBs is to obtain the connections of an existing item and recreate them elsewhere on other items. g2-get-connection-vertices system procedure for this purpose. The system procedure populates an integer list with the lengths of the connection segments and vertices of an existing connection. Positive values specify a segment extending upwards or to the right of an object or vertex, and negative numbers specify a segment extending downwards or to the left. Once populated, you can then use the list as the vertices specification for the create connection action and its given by integer-list grammar. create action uses the vertices contained in the list, and then determines the last one or two vertices based on the location of the item to which the newly-created connection is being attached.
Note: The g2-get-connection-vertices system procedure has changed in recent G2 releases and currently returns the minimum number of vertices that the create action requires, rather than the exact number of vertices from the original connection. For KBs that may have relied on the previous behavior, a backward compatibility option exists to revert the system procedure to its previous behavior. For information about that option, see Changing the Backward Compatibility.
The following
gds-get-connection-vertices procedure illustrates one way to use the system procedure in conjunction with the create connection action. This procedure creates a new object with connections identical to those of an existing item, which is passed to the procedure as an argument.
![]() |
Making a Transient Connection Permanent
Use the make action to make a transient connection permanent. The next example appends the make permanent action to the create action:
![]() |
Deleting a Connection
The delete action deletes a transient connection. You can delete a permanent connection by using the without permanence checks grammar. Deleting a connection leaves the stubs, unless you specify the optional removing connection stubs phrase, shown here:
![]() |
Making an item with connections transient, and then deleting that item, automatically deletes the connection stubs.
Hint: Transient connections and their stubs are deleted whenever you reset the KB.