Getting Information from a Connected Drawing

A Connect object has several properties that return information about the connection it represents. You can determine the shapes that are connected and the parts of a shape that are connected—for example, the top or side of a shape.

In this section…

Determining Which Shapes are Connected

Determining Which Parts of Shapes are Connected

Getting the Cells in a Connection

Guidelines for Analyzing a Connected Drawing

Determining Which Shapes are Connected

The FromSheet and ToSheet properties of a Connect object refer to Shape objects that represent the shapes that are connected. A shape is defined internally in Microsoft® Visio® in a sheet similar to the spreadsheet displayed for the shape in a ShapeSheet® window. These properties derive their names from this internal sheet.

FromSheet returns the shape that creates the connection; ToSheet returns the shape the connection is made to (the shape that receives the connection).

For example, suppose a drawing contains two shapes named Position and Executive, and the Position shape is glued to the Executive shape with a control handle. The Position shape's Connects collection contains one Connect object, whose FromSheet property returns Position and whose ToSheet property returns Executive.

To find out what shapes are glued to a particular shape, use the FromConnects property, which returns its Connects collection. The FromSheet property of each Connect object in the collection identifies each shape that the shape of interest is glued to. Continuing the example from the previous section Working with a Connect Object, of the four shapes A, B, C, and D, each glued to E, the FromSheet property of each Connect object returned from the FromConnects property of E refers to A, B, C, and D.

Tip When working with Connect objects in a collection returned by a shape's Connects property, you are typically looking for shapes a shape is connected to. The ToSheet property of each Connect object in the collection provides this information—the FromSheet property is always the same.

TOP

Determining Which Parts of Shapes are Connected

The FromPart and ToPart properties of a Connect object return integer constants that identify the general location of a connection on a shape. FromPart identifies the part of the shape from which a particular connection originates; ToPart identifies the part of the shape to which a particular connection is made. Constants for valid FromPart and ToPart values are defined in the Visio type library.

The following illustration shows the FromPart and ToPart values that would be returned to indicate the parts involved in typical connections in a drawing.

FromPart and ToPart values for typical connections in a drawing

FromPart and ToPart values for typical connections in a drawing

  1. visGuideIntersect (if a 2-D shape is glued to the guide), visGuideX (if a control handle is glued to the guide), or **visConnectionPoint+**i (if a 1-D shape is glued to the guide)
  1. visGuideIntersect (if a 2-D shape is glued to the guide), visGuideY (if a control handle is glued to the guide), or **visConnectionPoint+**i (if a 1-D shape is glued to the guide)
  1. visLeftEdge
  1. **visControlPoint+**i
  1. **visConnectionPoint+**i
  1. visBegin
  1. visEnd

The following table lists typical connections between shapes, and the constants for values returned by the FromPart and ToPart properties.

FromPart and ToPart constants for connections

Connection

FromPart constant

ToPart constant

Control handle glued to a connection point, guide, or guide point

visControlPoint+i

visConnectionPoint+i
visGuideX
visGuideY

1-D shape glued to a connection point

visBegin
visEnd

visConnectionPoint+i

2-D shape glued to a guide or guide point

visRightEdge
visLeftEdge
visTopEdge
visBottomEdge
visMiddleEdge
visCenterEdge

visGuideIntersect

1-D shape glued to a guide or guide point

visBeginX
visEndX
visBeginY
visEndY

visGuideIntersect

1-D shape dynamically glued to a shape

visBegin
visEnd

ObjType cell for the 1-D shape must include visLOFlagsRoutable and/or GlueType cell must include visGlueTypeWalking.

visWholeShape

To create dynamic or "walking" glue, the 1-D shape must connect to the pin of a shape that isn't a guide or a guide point.

For more details, see the FromPart and ToPart properties in the Microsoft Visio Developer Reference (on the Help menu, click Developer Reference).

Because a shape can have more than one control handle, visControlPoint is a base that represents the first control handle defined for a shape. If the value returned by FromPart is greater than visControlPoint, it represents the (*i+*1)th control handle for that shape. (To get i, subtract visControlPoint from the value returned by FromPart.) This is also true of visConnectionPoint—if the value returned by ToPart is greater than visConnectionPoint, it represents the (*i+*1)th connection point.

Gluing to a selection handle, vertex, or location within a shape automatically creates a connection point, which is why constants for these items are not defined. For details about the parts of a shape that can be glued, see What Can Be Glued to What in Creating a Connected Drawing from a Program later in this chapter.

TOP

Getting the Cells in a Connection

The FromCell and ToCell properties of a Connect object refer to Cell objects that represent the ShapeSheet cells involved in a connection. You can get or set the cell's formula, its result, or any other property of the Cell object and use it as you would any other Cell object—for example, as an argument to the GlueTo method.

TOP

Guidelines for Analyzing a Connected Drawing

When you are analyzing a connected drawing, you should keep the following in mind:

  • Know what kinds of shapes the drawing contains.
  • For example, does the drawing use 1-D shapes as connectors between 2-D shapes, or does it rely on control handles of 2-D shapes to draw lines from one shape to another? Are all lines between shapes instances of a connector master, or are some of them drawn with the
  • Line
  • tool?
  • Know that connection data you gather from a drawing created with the mouse may have different connections than you might assume from looking at the drawing.

Resistor and diode shapes stacked in a certain order. The stacking order of shapes can affect their connections.

Resistor and diode shapes stacked in a certain order. The stacking order of shapes can affect their connections.

  1. Because the resistor was glued first, it is glued to the guide.
  1. When the diode is then glued, it may either be glued to the guide, or it may be glued to the resistor.
  • Consider direction in the diagram; the parts of shapes that are glued might not correspond to directions that are indicated visually in a directed graph such as a flowchart.

For more details, see the FromCell and ToCell properties in the Microsoft Visio Developer Reference (on the Help menu, click Developer Reference).