
# IConnection interface

The `IConnection` interface represents whether the wire or bus connection has a manual junction on it or not, with location, wire or bus objects count and the thickness of wire or bus objects.

```csharp
public interface IConnection
```

**Namespace:** SCH · **Assembly:** Altium.SDK.Interfaces

## Remarks

The object count denotes the number of connections from this connection location for example one end of a capacitor can have two or more wire connections because it is tied to the Ground as well as to other points on the schematic. A connection that has 3 or more wire / bus objects denotes that a junction (system generated or manually placed) is required to tied the connections together. Thus you can use the `IConnection` interface to determine the number of wire or bus connections at the specified location.

The project that has schematics need to be compiled first before `IConnection` interfaces can be extracted with valid data.

The [`ISch_Sheet`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_Sheet.md) interface has the [`IConnectionsArray`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/IConnectionsArray.md) interface which in turn has the `IConnection` interface.

The [`ISch_Document`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_Document.md) can be either [`ISch_Sheet`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_Sheet.md) or [`ISch_Lib`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_Lib.md) interfaces depending on which document (Schematic Sheet or Schematic Library) you are working with.

A manual junction (placed by an user) may signify a forced connection of at least 3 or more connections on a schematic document.

## Example

Report the wire connections of the focused schematic document.

```csharp
using System.Collections.Generic;
using System.IO;
using DXP;
using EDP;
using SCH;

var ws = DXP.GlobalVars.Client.GetDXPWorkspace() as EDP.IWorkspace;
if (ws == null)
    return;
IProject prj = ws.DM_FocusedProject();
if (prj == null)
    return;
prj.DM_Compile();
IDocument doc = ws.DM_FocusedDocument();
var connectionsList = new List<string>();
if (doc.DM_DocumentKind() == "SCH")
{
    var currentSch = SCH.GlobalVars.SchServer.GetSchDocumentByPath(doc.DM_FullPath()) as ISch_Sheet;
    if (currentSch != null)
    {
        IConnectionsArray theWireConnections = currentSch.GetState_WireConnections();
        // Collect data for the wire connections.
        connectionsList.Add("Wire Connections");
        for (int j = 0; j < theWireConnections.GetState_ConnectionsCount(); j++)
        {
            IConnection wireConnection = theWireConnections.GetState_Connection(j);
            if (wireConnection != null)
            {
                DXP.Point location = wireConnection.GetState_Location();
                connectionsList.Add("Wire Connection Count: " + wireConnection.GetState_ObjectsCount());
                connectionsList.Add("Wire Connection Location: " + location.X + ", " + location.Y);
                connectionsList.Add("Wire Connection has a manual junction: " + wireConnection.GetState_IsManualJunction());
                connectionsList.Add("Wire Connection size: " + wireConnection.GetState_Size());
                connectionsList.Add("");
            }
        }
    }
}
string filePath = Path.GetDirectoryName(doc.DM_FullPath());
string fileName = Path.Combine(filePath, "ConnectionsReport.txt");
File.WriteAllLines(fileName, connectionsList);
IClient client = DXP.GlobalVars.Client;
IServerDocument reportDocument = client.OpenDocument("Text", fileName);
if (reportDocument != null)
    client.ShowDocument(reportDocument);
```

## Properties

| Property | Type | Access | Description |
| --- | --- | --- | --- |
| [IsManualJunction](#ismanualjunction) | `bool` | get; set | This property retrieves or sets the `IsManualJunction` setting of Bus or Wire connection represented by the `IConnection` object. |
| [Location](#location) | [Point](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/Point.md) | get; set | This property retrieves or sets the Location of Bus or Wire connection represented by the `IConnection` object. |
| [ObjectsCount](#objectscount) | `int` | get; set | This property retrieves or sets the Objects Count for Bus or Wire connection represented by the `IConnection` object. |
| [Size](#size) | [TSize](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/TSize.md) | get; set |  |

### IsManualJunction

This property retrieves or sets the `IsManualJunction` setting of Bus or Wire connection represented by the `IConnection` object.

```csharp
bool GetState_IsManualJunction();
void SetState_IsManualJunction(bool argValue);
```

**Type:** `bool` · **Access:** read/write

### Location

This property retrieves or sets the Location of Bus or Wire connection represented by the `IConnection` object.

```csharp
Point GetState_Location();
void SetState_Location(Point argValue);
```

**Type:** [Point](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/Point.md) · **Access:** read/write

The accessors are extension methods of `IConnectionHelper` (`using SCH;`).

### ObjectsCount

This property retrieves or sets the Objects Count for Bus or Wire connection represented by the `IConnection` object.

```csharp
int GetState_ObjectsCount();
void SetState_ObjectsCount(int argValue);
```

**Type:** `int` · **Access:** read/write

### Size

*No description yet.*

```csharp
TSize GetState_Size();
void SetState_Size(TSize argValue);
```

**Type:** [TSize](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/TSize.md) · **Access:** read/write

The accessors are extension methods of `IConnectionHelper` (`using SCH;`).

## Returned by

[IConnectionsArray.Connection](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/IConnectionsArray.md#connection), [IConnectionsArray.GetConnectionAt](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/IConnectionsArray.md#getconnectionat)
