
# IServerModule interface

A server deals with its own server documents. There can be different design document types, for example the Schematic Editor has two Schematic and Schematic Library document types.

```csharp
public interface IServerModule
```

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

**Derived:** [IMBA_ServerModule](https://altiumdeveloper.github.io/ad-sdk-docs/reference/edp/IMBA_ServerModule.md)

## Remarks

Each design document, in turn stores views which can be a document window or a panel window. A server has the ability to host multiple panel views for a single document view, see the diagram below.

A server also has the ability to host multiple global panel views that represent some system state and are not necessarily tied to a particular design document (for example the Work-Space Manager server has Message, Differences and Errors panels). This document view / multiple panel views structure is the foundation of Altium Designer client / server architecture.

This application manages single instances of different server modules. Each server can have multiple server document kinds, for example the PCB server supports two server document kinds - PCB and PCBLIB design documents. A loaded server in Altium Designer typically hosts documents and each document in turn hosts a document view and panel views.

The diagram below represents a server module with server documents. Each document has views - the document view and the associated panel view.

An `IServerModule` interface has the following interfaces:

• [`ICommandLauncher`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/ICommandLauncher.md) deals with a server's processes table

• [`IServerDocument`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerDocument.md) represents a loaded design document in Altium Designer

• [`IServerView`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerView.md) represents a panel that can have a view of the Altium Designer system

• [`IServerDocumentView`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerDocumentView.md) (deals with a document view (either the document window or panel window)

These forms are wrapped by the [`IServerDocumentView`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerDocumentView.md) or [`IServerView`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerView.md) interface object. This [`IExternalForm`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IExternalForm.md) interface object has low level methods such as resizing and displaying the form and is the ancestor interface for [`IServerDocumentView`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerDocumentView.md) and [`IServerView`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerView.md) interfaces.

• [`IProcessControl`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IProcessControl.md) represents the level of stacked processes for this focussed server document

• [`INotification`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/INotification.md) receives system notifications from the Client system and all server modules receive these notifications. There is an ability to handle a notification and take it from there. Documents and associated panels can be synchronized through the use of notifications as well.

The PCB server module also has its [`IPCB_ServerInterface`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ServerInterface.md) interface.

The Schematic Server module also has its ISCH_ServerInterface interface.

However both servers also have this `IServerModule` interface.

## Methods

| Method | Returns | Description |
| --- | --- | --- |
| [AddServerView](#addserverview) | `void` | This method adds a panel in the Server Module where this new panel can be used by the module. |
| [ApplicationIdle](#applicationidle) | `void` | The `ApplicationIdle` method is an internal method that gets invoked when Altium Designer is idling. |
| [CreateDocument](#createdocument) | [IServerDocument](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerDocument.md) | Creates a document supported by the server, of the given kind and with the given file name. |
| [CreateDocumentShowOrHide](#createdocumentshoworhide) | [IServerDocument](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerDocument.md) | The `CreateDocumentShowOrHide` method controls how a document when created is displayed in Altium Designer. |
| [CreateOptionsView](#createoptionsview) | [IDocumentOptionsView](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IDocumentOptionsView.md) | The `CreateOptionsView` creates a [`IDocumentOptions`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/IDocumentOptions.md) view to be used in the system wide Preferences dialog in Altium Designer. |
| [CreateServerDocView](#createserverdocview) | [IServerDocumentView](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerDocumentView.md) | The `CreateServerDocView` method creates an [`IServerDocumentView`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerDocumentView.md) (which could be the document or its associated panel view) object based on the Name of the document view and the [`IServerDocument`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerDocument.md) containe… |
| [CreateServerView](#createserverview) | [IServerView](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerView.md) | The `CreateServerView` method creates a [`IServerView`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerView.md) object representing a system panel. |
| [DestroyDocument](#destroydocument) | `void` | Closes and removes a design document. |
| [GetClient](#getclient) | [IClient](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IClient.md) | The `GetClient` method returns the [`IClient`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IClient.md) interface of the client subsystem of Altium Designer. |
| [GetCommandLauncher](#getcommandlauncher) | [ICommandLauncher](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/ICommandLauncher.md) | The [`CommandLauncher`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/CommandLauncher.md) method returns the [`ICommandLauncher`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/ICommandLauncher.md) interface. |
| [GetDocumentCount](#getdocumentcount) | `int` | The DocumentCount method returns you the number of Document Kinds. |
| [GetDocuments](#getdocuments) | [IServerDocument](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerDocument.md) | An editor type of server can have different document types, such as Schematic Editor and PCB Editor - these editor servers have two document types - SCH/SCHLIB and PCB/PCBLIB respectively. |
| [GetHandle](#gethandle) | `UIntPtr` | The method returns the handle of the server. |
| [GetModuleName](#getmodulename) | `string` | The method returns the module name of this server. |
| [GetProcessControl](#getprocesscontrol) | [IProcessControl](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IProcessControl.md) | The method returns the [`IProcessControl`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IProcessControl.md) interface. |
| [GetViewCount](#getviewcount) | `int` | The ViewCount method returns you the number of views for the specified server. |
| [GetViews](#getviews) | [IServerView](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerView.md) | The `GetViews` method in conjunction with the [`GetViewCount`](#getviewcount) method returns you the indexed View object. |
| [ReceiveNotification](#receivenotification) | `void` | The `ReceiveNotification` method of the server module intercepts notifications broadcasted by Altium Designer. |
| [RemoveServerView](#removeserverview) | `void` | The `RemoveServerView` method removes a [`IServerView`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerView.md) object in Altium Designer which represents a system panel. |

### AddServerView

This method adds a panel in the Server Module where this new panel can be used by the module.

```csharp
void AddServerView(IServerView argView);
void AddServerView(object argView);
```

| Parameter | Type | Passing |
| --- | --- | --- |
| `argView` | [IServerView](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerView.md) | value |

**Returns:** nothing (`void`)

The first overload is an extension method of `IServerModuleHelper` (`using DXP;`) with typed parameters; the second is declared by the interface.

Invoke this method after you have created a [`IServerView`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerView.md) object with the [`CreateServerView`](#createserverview) method or pass in the [`IServerView`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerView.md) interface parameter.

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

### ApplicationIdle

The `ApplicationIdle` method is an internal method that gets invoked when Altium Designer is idling. The `ApplicationIdle` method in all active running servers gets invoked. The messages sent by Altium Designer get the chance to be followed up.

```csharp
void ApplicationIdle();
```

**Returns:** nothing (`void`)

### CreateDocument

Creates a document supported by the server, of the given kind and with the given file name.

```csharp
IServerDocument CreateDocument(string argKind, string argFileName);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argKind` | `string` | value | The document kind that the server supports. |
| `argFileName` | `string` | value | The file name assigned to the new document. |

**Returns:** [IServerDocument](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerDocument.md)

Extension method of `IServerModuleHelper` (`using DXP;`).

### CreateDocumentShowOrHide

The `CreateDocumentShowOrHide` method controls how a document when created is displayed in Altium Designer.

```csharp
IServerDocument CreateDocumentShowOrHide(string argKind, string argFileName, bool argShowInTree);
```

| Parameter | Type | Passing |
| --- | --- | --- |
| `argKind` | `string` | value |
| `argFileName` | `string` | value |
| `argShowInTree` | `bool` | value |

**Returns:** [IServerDocument](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerDocument.md)

Extension method of `IServerModuleHelper` (`using DXP;`).

### CreateOptionsView

The `CreateOptionsView` creates a [`IDocumentOptions`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/sch/IDocumentOptions.md) view to be used in the system wide Preferences dialog in Altium Designer.

```csharp
IDocumentOptionsView CreateOptionsView(string argName);
```

| Parameter | Type | Passing |
| --- | --- | --- |
| `argName` | `string` | value |

**Returns:** [IDocumentOptionsView](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IDocumentOptionsView.md)

Extension method of `IServerModuleHelper` (`using DXP;`).

### CreateServerDocView

The `CreateServerDocView` method creates an [`IServerDocumentView`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerDocumentView.md) (which could be the document or its associated panel view) object based on the Name of the document view and the [`IServerDocument`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerDocument.md) container.

```csharp
IServerDocumentView CreateServerDocView(string argName, IServerDocument argDocument);
```

| Parameter | Type | Passing |
| --- | --- | --- |
| `argName` | `string` | value |
| `argDocument` | [IServerDocument](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerDocument.md) | value |

**Returns:** [IServerDocumentView](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerDocumentView.md)

Extension method of `IServerModuleHelper` (`using DXP;`).

### CreateServerView

The `CreateServerView` method creates a [`IServerView`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerView.md) object representing a system panel. You need to invoke the [`AddServerView`](#addserverview) method to add the object within Altium Designer.

```csharp
IServerView CreateServerView(string argName);
```

| Parameter | Type | Passing |
| --- | --- | --- |
| `argName` | `string` | value |

**Returns:** [IServerView](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerView.md)

Extension method of `IServerModuleHelper` (`using DXP;`).

### DestroyDocument

Closes and removes a design document.

```csharp
void DestroyDocument(IServerDocument argDocument);
void DestroyDocument(object argDocument);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argDocument` | [IServerDocument](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerDocument.md) | value | The design document to close and remove. |

**Returns:** nothing (`void`)

The first overload is an extension method of `IServerModuleHelper` (`using DXP;`) with typed parameters; the second is declared by the interface.

### GetClient

The `GetClient` method returns the [`IClient`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IClient.md) interface of the client subsystem of Altium Designer. This [`IClient`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IClient.md) interface can be used to invoke its methods.

```csharp
IClient GetClient();
```

**Returns:** [IClient](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IClient.md)

Extension method of `IServerModuleHelper` (`using DXP;`).

The `GetClient` method is used for the Client property.

The Client property returns the [`IClient`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IClient.md) interface of the client subsystem of Altium Designer. This [`IClient`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IClient.md) interface can be used to invoke its methods.

This readonly property is supported by the `GetClient` method.

### GetCommandLauncher

The [`CommandLauncher`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/CommandLauncher.md) method returns the [`ICommandLauncher`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/ICommandLauncher.md) interface. It is used to launch a process from its server module. The [`CommandLauncher`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/CommandLauncher.md) object contains a command table which binds a process name to the actual method that implements the process at run-time.

```csharp
ICommandLauncher GetCommandLauncher();
```

**Returns:** [ICommandLauncher](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/ICommandLauncher.md)

Extension method of `IServerModuleHelper` (`using DXP;`).

Whenever a process is called within the server this table is looked up in order to find the actual method pointer. If a process name is not found within this table then nothing will happen.

See the [`ICommandLauncher`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/ICommandLauncher.md) interface for more details.

This method is used for the [`CommandLauncher`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/CommandLauncher.md) property.

The [`CommandLauncher`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/CommandLauncher.md) property returns the pointer to the [`ICommandLauncher`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/ICommandLauncher.md) interface. It is used to launch a process from its server module. The [`CommandLauncher`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/CommandLauncher.md) object contains a command table which binds a process name to the actual method that implements the process at run-time.

Whenever a process is called within the server this table is looked up in order to find the actual method pointer. If a process name is not found within this table nothing will happen.

This read-only property is supported by the `GetCommandLauncher` method.

### GetDocumentCount

The DocumentCount method returns you the number of Document Kinds. An important note is that a View is the actual design document. A Document type is a container that stores specific Views.

```csharp
int GetDocumentCount();
```

**Returns:** `int`

This method is used for the DocumentCount property.

The DocumentCount property returns you the number of Document Kinds. An important note is that a View is the actual design document. A Document type is a container that stores specific Views.

This property is supported by the `GetDocumentCount` method.

### GetDocuments

An editor type of server can have different document types, such as Schematic Editor and PCB Editor - these editor servers have two document types - SCH/SCHLIB and PCB/PCBLIB respectively.

```csharp
IServerDocument GetDocuments(int argIndex);
```

| Parameter | Type | Passing |
| --- | --- | --- |
| `argIndex` | `int` | value |

**Returns:** [IServerDocument](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerDocument.md)

Extension method of `IServerModuleHelper` (`using DXP;`).

An add-on type of server will normally have no document containers, because they work with an editor server acting like a piggy back and utilising the editor server's API services.

This method returns you the indexed document container which is represented by the [`IServerDocument`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerDocument.md) interface.

This method is used for the Documents property.

This property returns you the indexed document container which is represented by the [`IServerDocument`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerDocument.md) interface.

This read only property is supported by the `GetDocuments` method.

**See also:** [IServerDocument](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerDocument.md), [IClient](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IClient.md)

### GetHandle

The method returns the handle of the server.

```csharp
UIntPtr GetHandle();
```

**Returns:** `UIntPtr`

Extension method of `IServerModuleHelper` (`using DXP;`).

This method is used for the Handle property.

The Handle property returns the handle of the server. This read only property is supported by the `GetHandle` method.

### GetModuleName

The method returns the module name of this server.

```csharp
string GetModuleName();
```

**Returns:** `string`

For example the texteditor server's module name is TextEdit. This server name property is defined in the associated server installation file (with an INS file extension).

This method is used for the ModuleName property.

The ModuleName property returns the module name of this server.

This read only property is supported by the `GetModuleName` method.

### GetProcessControl

The method returns the [`IProcessControl`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IProcessControl.md) interface. This interface controls the process depth for each design document in Altium Designer.

```csharp
IProcessControl GetProcessControl();
```

**Returns:** [IProcessControl](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IProcessControl.md)

Extension method of `IServerModuleHelper` (`using DXP;`).

Every time a process is launched on a document, the process depth is increased by one and once this same process has finished executing, the process depth is decreased by one. When the process depth is zero, it denotes that nothing is taking place on the current design document.

This read only property is supported by the `GetProcessControl` method.

The [`ProcessControl`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/ProcessControl.md) property returns the pointer to the [`IProcessControl`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IProcessControl.md) interface. This interface controls the process depth for each design document in Altium Designer.

### GetViewCount

The ViewCount method returns you the number of views for the specified server.

```csharp
int GetViewCount();
```

**Returns:** `int`

A View object encapsulates a form/window object in Altium Designer normally as a global panel supported by its associated server.

This method is used for the ViewCount property.

The ViewCount property returns you the number of views for the specified server.

This read only property is supported by the `GetViewCount` method.

### GetViews

The `GetViews` method in conjunction with the [`GetViewCount`](#getviewcount) method returns you the indexed View object. A view is a form supported by its associated server.

```csharp
IServerView GetViews(int argIndex);
```

| Parameter | Type | Passing |
| --- | --- | --- |
| `argIndex` | `int` | value |

**Returns:** [IServerView](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerView.md)

Extension method of `IServerModuleHelper` (`using DXP;`).

This method is used for the Views property.

The Views property in conjunction with the ViewCount property returns you the indexed View object. A view is a form supported by its associated server.

This read only property is supported by the `GetViews` method.

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

### ReceiveNotification

The `ReceiveNotification` method of the server module intercepts notifications broadcasted by Altium Designer.

```csharp
void ReceiveNotification(INotification argNotification);
void ReceiveNotification(object argNotification);
```

| Parameter | Type | Passing |
| --- | --- | --- |
| `argNotification` | [INotification](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/INotification.md) | value |

**Returns:** nothing (`void`)

The first overload is an extension method of `IServerModuleHelper` (`using DXP;`) with typed parameters; the second is declared by the interface.

The system has an [`IClient.BroadcastNotification`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IClient.md#broadcastnotification) or an [`IClient.DispatchNotification`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IClient.md#dispatchnotification) method which all running servers in Altium Designer can receive and process accordingly.

This method needs to be overridden and implemented.

### RemoveServerView

The `RemoveServerView` method removes a [`IServerView`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerView.md) object in Altium Designer which represents a system panel.

```csharp
void RemoveServerView(IServerView argView);
void RemoveServerView(object argView);
```

| Parameter | Type | Passing |
| --- | --- | --- |
| `argView` | [IServerView](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerView.md) | value |

**Returns:** nothing (`void`)

The first overload is an extension method of `IServerModuleHelper` (`using DXP;`) with typed parameters; the second is declared by the interface.

## Returned by

[IClient.GetServerModule](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IClient.md#getservermodule), [IClient.GetServerModuleByName](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IClient.md#getservermodulebyname), [IServerDocument.GetServerModule](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IServerDocument.md#getservermodule), [GlobalVars.Server](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/GlobalVars.md#server)

## Accepted by

[IClient.DisableServerNotificationHandler](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IClient.md#disableservernotificationhandler), [IClient.DispatchNotification](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IClient.md#dispatchnotification), [IClient.RegisterServerNotificationHandler](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IClient.md#registerservernotificationhandler), [IClient.UnregisterServerNotificationHandler](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/IClient.md#unregisterservernotificationhandler)

## Examples

Used in the SDK examples: [Ciiva](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Ciiva/Source%20Code/CiivaBOMDocument.cs#L25), [Extension_BOMManager](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Extension_BOMManager/Source%20Code/Commands.cs#L180), [Extension_BOMManager](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Extension_BOMManager/Source%20Code/SchemaBom.cs#L96).
