
# IDeviceSheetManager interface

The `IDeviceSheetManager` interface represents the Device Sheets Folder dialog in Altium Designer. Invoke the DeviceSheetManager method to fetch the `IDeviceSheetManager` object interface.

```csharp
public interface IDeviceSheetManager
```

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

## Methods

| Method | Returns | Description |
| --- | --- | --- |
| [AddDeviceFolder](#adddevicefolder) | `bool` | This method adds a new device folder into the existing top level Device Folder and whether sub folders can be searched from that folder. |
| [BrowseDeviceSheet](#browsedevicesheet) | `bool` | The method `BrowseDeviceSheet` invokes the Select Device Sheet dialog and, when you select a device sheet, returns the filename (without the file extension) of the device sheet you chose from this dial… |
| [ChooseDeviceFolder](#choosedevicefolder) | `bool` | This method invokes the Choose Device Sheet Folder dialog and returns you the valid device folder. |
| [ClearFolders](#clearfolders) | `void` |  |
| [ConvertDeviceSheetPathToName](#convertdevicesheetpathtoname) | `string` | The method converts the full file path of the device sheet to the valid device sheet filename (without the file extension). |
| [DeleteFolder](#deletefolder) | `void` |  |
| [EditDeviceFolderList](#editdevicefolderlist) | `void` | This method invokes the Device Sheet Folders dialog with all Device Sheet Folders if any. |
| [FindAllDeviceSheetPaths](#findalldevicesheetpaths) | `string` |  |
| [FindDeviceSheetPath](#finddevicesheetpath) | `string` | This method finds the Device Sheet path for the valid device sheet (without the file extension). |
| [GetCurrentProject](#getcurrentproject) | [IProject](https://altiumdeveloper.github.io/ad-sdk-docs/reference/edp/IProject.md) |  |
| [GetFolders_FolderPath](#getfolders_folderpath) | `string` | This method returns the indexed path of device sheets (as in the Device Sheet Folders dialog). |
| [GetFolders_SearchSubFolders](#getfolders_searchsubfolders) | `bool` | This method returns a boolean result for sub folders of the indexed path of device sheets (as in the Device Sheet Folders dialog). |
| [GetFoldersCount](#getfolderscount) | `int` | The `GetFoldersCount` method returns the number of Device Sheet Folders in Altium Designer. |
| [MakeCurrentProject](#makecurrentproject) | `void` |  |
| [SetDeviceFolder](#setdevicefolder) | `void` |  |
| [WillSearchDeviceFolder](#willsearchdevicefolder) | `bool` | This method determines whether a Device Sheet Folder exists or not. |

### AddDeviceFolder

This method adds a new device folder into the existing top level Device Folder and whether sub folders can be searched from that folder.

```csharp
bool AddDeviceFolder(string argFolderPath, bool argSearchSubfolder);
```

| Parameter | Type | Passing |
| --- | --- | --- |
| `argFolderPath` | `string` | value |
| `argSearchSubfolder` | `bool` | value |

**Returns:** `bool`

### BrowseDeviceSheet

The method `BrowseDeviceSheet` invokes the Select Device Sheet dialog and, when you select a device sheet, returns the filename (without the file extension) of the device sheet you chose from this dialog.

```csharp
bool BrowseDeviceSheet(ref string argFileName, out string argFilePath);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argFileName` | `string` | ref | Returns the filename (without the file extension) of the device sheet you chose. |
| `argFilePath` | `string` | out |  |

**Returns:** `bool`

**Example:** Let the user browse for a device sheet and show its file name.

```csharp
using SCH;

IDeviceSheetManager deviceSheetMan = EDP.Utils.GetDeviceSheetManager();
if (deviceSheetMan == null)
    return;
string aFileName = "";
string aFilePath;
deviceSheetMan.BrowseDeviceSheet(ref aFileName, out aFilePath);
DXP.Utils.ShowMessage("Filename " + aFileName);
```

### ChooseDeviceFolder

This method invokes the Choose Device Sheet Folder dialog and returns you the valid device folder. The method returns a false value if the dialog is cancelled.

```csharp
bool ChooseDeviceFolder(ref string argFolderPath);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argFolderPath` | `string` | ref | Returns the valid device folder. |

**Returns:** `bool`

**Example:** Let the user choose another folder for a device sheet path.

```csharp
using System.IO;
using SCH;

IDeviceSheetManager deviceSheetManager = EDP.Utils.GetDeviceSheetManager();
if (deviceSheetManager == null)
    return;
string deviceSheetPathText = "<device sheet path>";

string folderPath = Path.GetDirectoryName(deviceSheetPathText);
if (deviceSheetManager.ChooseDeviceFolder(ref folderPath))
    deviceSheetPathText = Path.Combine(folderPath, Path.GetFileName(deviceSheetPathText));
```

**Examples:** [Extension_TestCS](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Extension_TestCS/Source%20Code/Commands.cs#L33)

### ClearFolders

*No description yet.*

```csharp
void ClearFolders();
```

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

### ConvertDeviceSheetPathToName

The method converts the full file path of the device sheet to the valid device sheet filename (without the file extension). If the file path is invalid, an empty string is returned.

```csharp
string ConvertDeviceSheetPathToName(string argFilePath);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argFilePath` | `string` | value | The full file path of the device sheet. |

**Returns:** `string`

**Example:** Show the name of a device sheet from its path.

```csharp
using SCH;

IDeviceSheetManager deviceSheetMan = EDP.Utils.GetDeviceSheetManager();
if (deviceSheetMan == null)
    return;
// Shows the file name of the device sheet without the file extension.
DXP.Utils.ShowMessage(deviceSheetMan.ConvertDeviceSheetPathToName("<device sheet path>"));
```

### DeleteFolder

*No description yet.*

```csharp
void DeleteFolder(int argIndex);
```

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

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

### EditDeviceFolderList

This method invokes the Device Sheet Folders dialog with all Device Sheet Folders if any.

```csharp
void EditDeviceFolderList();
```

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

**Example:** Open the dialog that edits the list of device sheet folders.

```csharp
using SCH;

IDeviceSheetManager deviceSheetMan = EDP.Utils.GetDeviceSheetManager();
if (deviceSheetMan == null)
    return;
deviceSheetMan.EditDeviceFolderList();
```

### FindAllDeviceSheetPaths

*No description yet.*

```csharp
string FindAllDeviceSheetPaths(string argFileName, out string argOtherMatchingPaths);
```

| Parameter | Type | Passing |
| --- | --- | --- |
| `argFileName` | `string` | value |
| `argOtherMatchingPaths` | `string` | out |

**Returns:** `string`

### FindDeviceSheetPath

This method finds the Device Sheet path for the valid device sheet (without the file extension). If the file name is invalid, a blank string is returned.

```csharp
string FindDeviceSheetPath(string argFileName);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argFileName` | `string` | value | Defines the valid device sheet (without the file extension). |

**Returns:** `string`

**Example:** Show the path of a device sheet from its name.

```csharp
using SCH;

IDeviceSheetManager deviceSheetMan = EDP.Utils.GetDeviceSheetManager();
if (deviceSheetMan == null)
    return;
DXP.Utils.ShowMessage(deviceSheetMan.FindDeviceSheetPath("<device sheet name>"));
```

**Examples:** [Extension_PlaceDeviceSheet](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Extension_PlaceDeviceSheet/Source%20Code/Commands.cs#L51)

### GetCurrentProject

*No description yet.*

```csharp
IProject GetCurrentProject();
```

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

Extension method of `IDeviceSheetManagerHelper` (`using SCH;`).

### GetFolders_FolderPath

This method returns the indexed path of device sheets (as in the Device Sheet Folders dialog). The first entry starts at zero (0).

```csharp
string GetFolders_FolderPath(int argIndex);
```

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

**Returns:** `string`

**Example:** Show the path of the last device sheet folder.

```csharp
using SCH;

IDeviceSheetManager deviceSheetMan = EDP.Utils.GetDeviceSheetManager();
if (deviceSheetMan == null)
    return;
int count = deviceSheetMan.GetFoldersCount();
DXP.Utils.ShowMessage(deviceSheetMan.GetFolders_FolderPath(count - 1));
```

**See also:** [IDeviceSheetManager.GetFoldersCount](#getfolderscount)

### GetFolders_SearchSubFolders

This method returns a boolean result for sub folders of the indexed path of device sheets (as in the Device Sheet Folders dialog). The first entry starts at zero (0).

```csharp
bool GetFolders_SearchSubFolders(int argIndex);
```

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

**Returns:** `bool`

**Example:** Check whether the sub folders of the first device sheet folder are searched.

```csharp
using SCH;

IDeviceSheetManager deviceSheetMan = EDP.Utils.GetDeviceSheetManager();
if (deviceSheetMan == null)
    return;
bool result = deviceSheetMan.GetFolders_SearchSubFolders(0);
if (result)
    DXP.Utils.ShowMessage(deviceSheetMan.GetFolders_FolderPath(0) + " has its sub folders");
```

**See also:** [IDeviceSheetManager.GetFoldersCount](#getfolderscount)

### GetFoldersCount

The `GetFoldersCount` method returns the number of Device Sheet Folders in Altium Designer.

```csharp
int GetFoldersCount();
```

**Returns:** `int`

**Example:** Show the number of device sheet folders.

```csharp
using SCH;

IDeviceSheetManager deviceSheetMan = EDP.Utils.GetDeviceSheetManager();
if (deviceSheetMan == null)
    return;
int count = deviceSheetMan.GetFoldersCount();
DXP.Utils.ShowMessage(count.ToString());
```

### MakeCurrentProject

*No description yet.*

```csharp
void MakeCurrentProject(IProject argProject);
void MakeCurrentProject(object argProject);
```

| Parameter | Type | Passing |
| --- | --- | --- |
| `argProject` | [IProject](https://altiumdeveloper.github.io/ad-sdk-docs/reference/edp/IProject.md) | value |

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

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

### SetDeviceFolder

*No description yet.*

```csharp
void SetDeviceFolder(int argIndex, string argFolderPath, bool argSearchSubfolder);
```

| Parameter | Type | Passing |
| --- | --- | --- |
| `argIndex` | `int` | value |
| `argFolderPath` | `string` | value |
| `argSearchSubfolder` | `bool` | value |

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

### WillSearchDeviceFolder

This method determines whether a Device Sheet Folder exists or not.

```csharp
bool WillSearchDeviceFolder(string argFolderPath);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argFolderPath` | `string` | value | Represents the Device Sheet Folder. |

**Returns:** `bool`

**Example:** Add the folder of a device sheet to the device sheet folders unless it is searched already.

```csharp
using System.IO;
using SCH;

IDeviceSheetManager deviceSheetManager = EDP.Utils.GetDeviceSheetManager();
if (deviceSheetManager == null)
    return;
string aSheetPath = "<device sheet path>";

if (!deviceSheetManager.WillSearchDeviceFolder(Path.GetDirectoryName(aSheetPath)))
    deviceSheetManager.AddDeviceFolder(Path.GetDirectoryName(aSheetPath), false);
```

## Returned by

[Utils.GetDeviceSheetManager](https://altiumdeveloper.github.io/ad-sdk-docs/reference/edp/Utils.md#getdevicesheetmanager)

## Examples

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