
# ISch_Port interface

A port is used to connect a net on one sheet to Ports with the same name on other sheets. Ports can also connect from child sheets to Sheet entries, in the appropriate sheet symbol on the parent sheet.

```csharp
public interface ISch_Port : ISch_ParametrizedGroup
```

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

**Inherits:** [ISch_BasicContainer](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_BasicContainer.md) → [ISch_GraphicalObject](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md) → [ISch_ParametrizedGroup](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_ParametrizedGroup.md)

## Remarks

The port cross referencing information for ports on different schematics linked to sheet entries of a sheet symbol can be added to schematic sheets by executing the Reports » Port Cross Reference » Add To Sheet or Add to Project command within Schematic Editor in Altium Designer.

To obtain the cross reference field of a port, the design project needs to be compiled first and then port cross-referencing information added to the project or the sheet.

Port cross references are a calculated attribute of ports, they can not be edited and are not stored with the design.

The location of each port reference is determined by the location of the port on the sheet and the position of the connecting wire.

The CrossReference property returns the name of the sheet the port is linked to and the grid where the port is located at. Example : 4 Port Serial Interface .

## Properties

| Property | Type | Access | Description |
| --- | --- | --- | --- |
| [Alignment](#alignment) | [THorizontalAlign](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/THorizontalAlign.md) | get; set | The Alignment property determines how the port's Name is aligned with respect to the ends of the port itself. |
| [AutoSize](#autosize) | `bool` | get; set |  |
| [BorderWidth](#borderwidth) | [TSize](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/TSize.md) | get; set |  |
| [ConnectedEnd](#connectedend) | [TPortConnectedEnd](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/TPortConnectedEnd.md) | get; set | The `ConnectedEnd` property determines how a port object is connected graphically with the [`TPortConnectedEnd`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/TPortConnectedEnd.md) type. |
| [CrossRef](#crossref) | `string` | get; set | Port Cross References are text that show which schematic sheets the ports are linked to with the zone reference information in brackets. |
| [FontId](#fontid) | `int` | get; set |  |
| [HarnessColor](#harnesscolor) | `int` | get; set |  |
| [Height](#height) | `int` | get; set |  |
| [IOType](#iotype) | [TPortIO](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/TPortIO.md) | get; set | The `IOType` property defines the electrical properties of the port with the [`TPortIO`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/TPortIO.md) type. |
| [IsCustomStyle](#iscustomstyle) | `bool` | get |  |
| [Name](#name) | `string` | get; set | The Name property determines the name for the port object. |
| [OverrideDisplayString](#overridedisplaystring) | `string` | get; set | The OverrrideDisplayString property determines the override display string which overrides the Name string. |
| [Style](#style) | [TPortArrowStyle](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/TPortArrowStyle.md) | get; set | The Style property determines the style of the port object. |
| [TextColor](#textcolor) | `int` | get; set | The `TextColor` property determines the color (a value of TColor type) of the Port's Name string. |
| [Width](#width) | `int` | get; set | This `SetState_Width` method sets the width of the port object in a TCoord value. |

### Alignment

The Alignment property determines how the port's Name is aligned with respect to the ends of the port itself. The Name string can be left justified, centered or right justified.

```csharp
THorizontalAlign GetState_Alignment();
void SetState_Alignment(THorizontalAlign argValue);
```

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

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

**See also:** [THorizontalAlign](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/THorizontalAlign.md)

### AutoSize

*No description yet.*

```csharp
bool GetState_AutoSize();
void SetState_AutoSize(bool argValue);
```

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

### BorderWidth

*No description yet.*

```csharp
TSize GetState_BorderWidth();
void SetState_BorderWidth(TSize argValue);
```

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

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

### ConnectedEnd

The `ConnectedEnd` property determines how a port object is connected graphically with the [`TPortConnectedEnd`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/TPortConnectedEnd.md) type.

```csharp
TPortConnectedEnd GetState_ConnectedEnd();
void SetState_ConnectedEnd(TPortConnectedEnd argValue);
```

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

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

**See also:** [TPortConnectedEnd](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/TPortConnectedEnd.md)

### CrossRef

Port Cross References are text that show which schematic sheets the ports are linked to with the zone reference information in brackets. For example a port with A[0..2] name on 4 Port UART and Line Drivers.SchDoc will have a string with "ISA and Address Decoding" and the 4C string represents the location (reference zone markers around the schematic sheet) of the matching port on ISA and Address Decoding.SchDoc. The string in the [] bracket is dependent on the Port Cross References options in the Schematic – General page of the Preferences dialog.

```csharp
string GetState_CrossRef();
void SetState_CrossRef(string argValue);
```

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

Port Cross References are generated from the Reports » Port Cross Reference » Add to Sheet or Reports » Port Cross Reference » Add to Project commands in the Schematic Editor.

The `CrossRef` string is also represented as a parameter associated with this port object AFTER the port cross reference command from the Reports menu has been invoked.

**Example:** Report the cross reference of every port on the current schematic sheet.

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

ISch_Document currentSheet = SCH.GlobalVars.SchServer?.GetCurrentSchDocument();
if (currentSheet == null)
    return;

var report = new List<string>();
ISch_Iterator iterator = currentSheet.SchIterator_Create();
iterator.AddFilter_ObjectSet(new SCH.TObjectSet { TObjectId.ePort });
try
{
    for (var port = iterator.FirstSchObject() as ISch_Port; port != null; port = iterator.NextSchObject() as ISch_Port)
    {
        if (port.GetState_CrossRef() != "")
            report.Add("Port:" + port.GetState_Name() + "'s cross reference: " + port.GetState_CrossRef());
        else
            report.Add("Port:" + port.GetState_Name() + " does not have a cross reference.");
    }
}
finally
{
    currentSheet.SchIterator_Destroy(ref iterator);
}

string reportPath = Path.Combine(Path.GetTempPath(), "PortReport.txt");
File.WriteAllLines(reportPath, report);
IClient client = DXP.GlobalVars.Client;
IServerDocument reportDocument = client.OpenDocument("Text", reportPath);
if (reportDocument != null)
    client.ShowDocument(reportDocument);
```

### FontId

*No description yet.*

```csharp
int GetState_FontId();
void SetState_FontId(int argFontId);
```

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

### HarnessColor

*No description yet.*

```csharp
int GetState_HarnessColor();
void SetState_HarnessColor(int argValue);
```

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

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

### Height

*No description yet.*

```csharp
int GetState_Height();
void SetState_Height(int argValue);
```

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

### IOType

The `IOType` property defines the electrical properties of the port with the [`TPortIO`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/TPortIO.md) type. Available Port IO types are: Input, Output, Bi-directional and Unspecified.

```csharp
TPortIO GetState_IOType();
void SetState_IOType(TPortIO argValue);
```

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

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

The setting of this IO Type does not influence the connectivity of the circuit, but is considered during the running of an electrical rules check, which can be set to detect incompatible port directions.

**See also:** [TPortIO](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/TPortIO.md)

### IsCustomStyle

*No description yet.*

```csharp
bool GetState_IsCustomStyle();
```

**Type:** `bool` · **Access:** read-only

### Name

The Name property determines the name for the port object.

```csharp
string GetState_Name();
void SetState_Name(string argValue);
```

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

### OverrideDisplayString

The OverrrideDisplayString property determines the override display string which overrides the Name string.

```csharp
string GetState_OverrideDisplayString();
void SetState_OverrideDisplayString(string argValue);
```

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

### Style

The Style property determines the style of the port object. This style is determined by the [`TPortArrowStyle`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/TPortArrowStyle.md) type. This style defines the graphical style of the port object.

```csharp
TPortArrowStyle GetState_Style();
void SetState_Style(TPortArrowStyle argValue);
```

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

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

**See also:** [TPortArrowStyle](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/TPortArrowStyle.md)

### TextColor

The `TextColor` property determines the color (a value of TColor type) of the Port's Name string.

```csharp
int GetState_TextColor();
void SetState_TextColor(int argValue);
```

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

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

The TColor value specifies a 6 digit hexadecimal number of the $FFFFFF format. For example the color blue would be RGB:0,0,255 and Hex:FF0000 therefore the converted decimal value would be 16711680. The following formula may be used to calculate the required value, R+256*(G+(256*B)).

### Width

This `SetState_Width` method sets the width of the port object in a TCoord value. Use one of the following conversion methods to convert from a unit value to a TCoord value. For example [`EDP.Utils.MilsToCoord`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/edp/Utils.md#milstocoord).

```csharp
int GetState_Width();
void SetState_Width(int argValue);
```

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

The `GetState_Width` method gets the width of the port in TCoord type. Use one of the following conversion methods to convert from a TCoord value to one of these Unit values. For example [`EDP.Utils.CoordToMils`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/edp/Utils.md#coordtomils).

## Methods

| Method | Returns | Description |
| --- | --- | --- |
| [IsVertical](#isvertical) | `bool` | This method returns a Boolean value that determines whether the port object is aligned vertically or not. |

### IsVertical

This method returns a Boolean value that determines whether the port object is aligned vertically or not.

```csharp
bool IsVertical();
```

**Returns:** `bool`

## Inherited members

- From [ISch_ParametrizedGroup](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_ParametrizedGroup.md): [Import_FromUser_Parameters](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_ParametrizedGroup.md#import_fromuser_parameters), [ResetAllSchParametersPosition](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_ParametrizedGroup.md#resetallschparametersposition)
- From [ISch_GraphicalObject](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md): [AddErrorString](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md#adderrorstring), [AreaColor](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md#areacolor), [BoundingRectangle](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md#boundingrectangle), [BoundingRectangle_Full](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md#boundingrectangle_full), [Color](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md#color), [CompilationMasked](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md#compilationmasked), [Dimmed](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md#dimmed), [Disabled](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md#disabled), [DisplayError](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md#displayerror), [EnableDraw](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md#enabledraw), [ErrorColor](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md#errorcolor), [ErrorKind](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md#errorkind), [ErrorString](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md#errorstring), [GetHash](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md#gethash), [GraphicallyInvalidate](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md#graphicallyinvalidate), [LiveHighlightValue](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md#livehighlightvalue), [Location](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md#location), [Mirror](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md#mirror), [MoveByXY](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md#movebyxy), [MoveToXY](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md#movetoxy), [OwnerPartDisplayMode](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md#ownerpartdisplaymode), [OwnerPartId](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md#ownerpartid), [ResetErrorFields](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md#reseterrorfields), [RotateBy90](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md#rotateby90), [Selection](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md#selection), [SetState_xSizeySize](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_GraphicalObject.md#setstate_xsizeysize)
- From [ISch_BasicContainer](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_BasicContainer.md): [AddAndPositionSchObject](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_BasicContainer.md#addandpositionschobject), [AddSchObject](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_BasicContainer.md#addschobject), [CopyTo](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_BasicContainer.md#copyto), [DeleteAll](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_BasicContainer.md#deleteall), [DescriptionString](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_BasicContainer.md#descriptionstring), [ExportToParameters](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_BasicContainer.md#exporttoparameters), [FreeAllContainedObjects](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_BasicContainer.md#freeallcontainedobjects), [Handle](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_BasicContainer.md#handle), [IdentifierString](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_BasicContainer.md#identifierstring), [Import_FromUser](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_BasicContainer.md#import_fromuser), [ObjectId](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_BasicContainer.md#objectid), [OwnerSchDocument](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_BasicContainer.md#ownerschdocument), [RemoveSchObject](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_BasicContainer.md#removeschobject), [Replicate](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_BasicContainer.md#replicate), [SchBasicContainer](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_BasicContainer.md#schbasiccontainer), [SchIterator_Create](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_BasicContainer.md#schiterator_create), [SchIterator_Destroy](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_BasicContainer.md#schiterator_destroy), [SchParameterByName](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_BasicContainer.md#schparameterbyname), [Setstate_Default](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_BasicContainer.md#setstate_default), [Text](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_BasicContainer.md#text), [UniqueId](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_BasicContainer.md#uniqueid), [WiringDiagramOriginUniqueId](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/ISch_BasicContainer.md#wiringdiagramoriginuniqueid)

## Examples

Used in the SDK examples: [Extension_TestPortHarnessDev](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Extension_TestPortHarnessDev/Source%20Code/Commands.cs#L59).
