
# IPCB_Library interface

A PCB library document. A library document has a list of components (footprints), each an [`IPCB_LibComponent`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibComponent.md); the component in focus in the library is the current component.

```csharp
public interface IPCB_Library
```

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

## Remarks

The current PCB library is returned by [`IPCB_ServerInterface.GetCurrentPCBLibrary`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ServerInterface.md#getcurrentpcblibrary).

To obtain the settings of the library document, use its [`IPCB_Board`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Board.md) (`Board`); to obtain the primitives of a footprint, obtain its [`IPCB_LibComponent`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibComponent.md), for example with the library iterator ([`LibraryIterator_Create`](#libraryiterator_create)).

All components of a library share the one board. The primitives of the current component are on that board: making another component current moves the primitives of the previous one off the board and the primitives of the new one onto it.

## Properties

| Property | Type | Access | Description |
| --- | --- | --- | --- |
| [Board](#board) | [IPCB_Board](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Board.md) | get | The board of the PCB library document, on which the primitives of the current component reside. |
| [CurrentComponent](#currentcomponent) | [IPCB_LibComponent](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibComponent.md) | get; set | The current component (footprint), the one that is in focus or displayed in the PCB library document in Altium Designer. |
| [FolderGUID](#folderguid) | `string` | get; set | The GUID of the vault folder that the library document is linked to. |
| [IsSingleComponentMode](#issinglecomponentmode) | `bool` | get | Whether the library is in single-component mode. |
| [LibraryID](#libraryid) | `int` | get | A number that identifies the library while Altium Designer runs. |
| [LifeCycleDefinitionGUID](#lifecycledefinitionguid) | `string` | get; set | The GUID of the life cycle definition of the library document's vault link. |
| [RevisionNamingSchemeGUID](#revisionnamingschemeguid) | `string` | get; set | The GUID of the revision naming scheme of the library document's vault link. |
| [VaultGUID](#vaultguid) | `string` | get; set | The GUID of the vault that the library document is linked to. |

### Board

The board of the PCB library document, on which the primitives of the current component reside.

```csharp
IPCB_Board GetState_Board();
```

**Type:** [IPCB_Board](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Board.md) · **Access:** read-only

The accessors are extension methods of `IPCB_LibraryHelper` (`using PCB;`).

The board also holds the settings of the library document, such as the grids and the output options.

### CurrentComponent

The current component (footprint), the one that is in focus or displayed in the PCB library document in Altium Designer.

```csharp
IPCB_LibComponent GetState_CurrentComponent();
void SetState_CurrentComponent(IPCB_LibComponent argComponent);
```

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

The accessors are extension methods of `IPCB_LibraryHelper` (`using PCB;`).

Assigning a component moves the primitives of the previous current component off the library's `Board` and the primitives of the new one onto it. Assigning null, or a component that is not registered in this library, does nothing: when creating a new footprint programmatically, register it with [`RegisterComponent`](#registercomponent) before making it the current component.

**See also:** [IPCB_Group](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Group.md), [IPCB_LibComponent](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibComponent.md)

### FolderGUID

The GUID of the vault folder that the library document is linked to.

```csharp
string GetState_FolderGUID();
void SetState_FolderGUID(string argValue);
```

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

### IsSingleComponentMode

Whether the library is in single-component mode.

```csharp
bool GetState_IsSingleComponentMode();
```

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

The mode is set from the library's file name when the file name is assigned; it is true when the document is a file-less model.

### LibraryID

A number that identifies the library while Altium Designer runs.

```csharp
int GetState_LibraryID();
```

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

Each library gets the next number when it is created.

### LifeCycleDefinitionGUID

The GUID of the life cycle definition of the library document's vault link.

```csharp
string GetState_LifeCycleDefinitionGUID();
void SetState_LifeCycleDefinitionGUID(string argValue);
```

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

### RevisionNamingSchemeGUID

The GUID of the revision naming scheme of the library document's vault link.

```csharp
string GetState_RevisionNamingSchemeGUID();
void SetState_RevisionNamingSchemeGUID(string argValue);
```

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

### VaultGUID

The GUID of the vault that the library document is linked to.

```csharp
string GetState_VaultGUID();
void SetState_VaultGUID(string argValue);
```

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

Changing a non-empty value to a different one clears [`IPCB_LibComponent.ItemGUID`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibComponent.md#itemguid) and [`IPCB_LibComponent.ItemRevisionGUID`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibComponent.md#itemrevisionguid) of every component in the library.

## Methods

| Method | Returns | Description |
| --- | --- | --- |
| [AddComponent](#addcomponent) | [IPCB_LibComponent](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibComponent.md) | Does nothing and returns null. |
| [ComponentCount](#componentcount) | `int` | Returns the number of components (footprints) in the library. |
| [CreateNewComponent](#createnewcomponent) | [IPCB_LibComponent](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibComponent.md) | Creates a new component (footprint) and adds it to the library. |
| [DeRegisterComponent](#deregistercomponent) | `bool` | De-registers a component from the library, so that the library no longer recognizes it. |
| [GetComponent](#getcomponent) | [IPCB_LibComponent](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibComponent.md) | Returns the component (footprint) at the given position in the library's component list. |
| [GetComponentByName](#getcomponentbyname) | [IPCB_LibComponent](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibComponent.md) | Returns the component (footprint) with the given name, or null when the library has no component of that name. |
| [GetUniqueCompName](#getuniquecompname) | `string` | Returns a component name that is not yet used in the library, based on the given name. |
| [HasServerDocument](#hasserverdocument) | `bool` | Returns whether the library has a `Board` and that board is attached to a server document. |
| [LibraryIterator_Create](#libraryiterator_create) | [IPCB_LibraryIterator](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibraryIterator.md) | Creates an iterator that fetches the footprints ([`IPCB_LibComponent`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibComponent.md)) of the library. |
| [LibraryIterator_Destroy](#libraryiterator_destroy) | `void` | Destroys a library iterator created by [`LibraryIterator_Create`](#libraryiterator_create). |
| [LibraryLoaderSaver_Create](#libraryloadersaver_create) | [IPCB_LibraryLoaderSaver](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibraryLoaderSaver.md) | Creates a library loader-saver ([`IPCB_LibraryLoaderSaver`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibraryLoaderSaver.md)). |
| [LibraryLoaderSaver_Destroy](#libraryloadersaver_destroy) | `void` | Destroys a library loader-saver created by [`LibraryLoaderSaver_Create`](#libraryloadersaver_create). |
| [LinkDocumentToReleaseVault](#linkdocumenttoreleasevault) | `bool` | Links the library document to a vault folder and item, and returns whether this succeeded. |
| [Navigate_FirstComponent](#navigate_firstcomponent) | `void` | Navigates to the first component of the library and sets the focus to it. |
| [RefreshView](#refreshview) | `void` | Does nothing. |
| [RegisterComponent](#registercomponent) | `bool` | Registers a new footprint in the library. |
| [ReleaseDocument](#releasedocument) | `bool` | Releases the library document to the vault, and returns whether the release succeeded. |
| [RemoveComponent](#removecomponent) | `void` | Removes a component from the library. |
| [SaveComponentWithLibrary](#savecomponentwithlibrary) | `bool` | Saves one component of the library to a new PCB library file, and returns whether this succeeded. |
| [SaveEmptyLibrary](#saveemptylibrary) | `bool` | Saves a PCB library file that has the library's settings and no components, and returns whether this succeeded. |
| [SetBoardToComponentByName](#setboardtocomponentbyname) | `bool` | Makes the component with the given name the current component, and returns whether this succeeded. |
| [SetCurrentComponentReference](#setcurrentcomponentreference) | `void` | Sets the origin of the library's board, the reference point of the component in focus. |
| [SplitIntoComponents](#splitintocomponents) | `void` | Saves each component of the library to its own PCB library file in a folder. |

### AddComponent

Does nothing and returns null.

```csharp
IPCB_LibComponent AddComponent(string argName);
```

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

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

Extension method of `IPCB_LibraryHelper` (`using PCB;`).

To add a footprint, use [`CreateNewComponent`](#createnewcomponent), or create one with [`IPCB_ServerInterface.CreatePCBLibComp`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ServerInterface.md#createpcblibcomp) and add it with [`RegisterComponent`](#registercomponent).

### ComponentCount

Returns the number of components (footprints) in the library.

```csharp
int ComponentCount();
```

**Returns:** `int`

### CreateNewComponent

Creates a new component (footprint) and adds it to the library.

```csharp
IPCB_LibComponent CreateNewComponent();
```

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

Extension method of `IPCB_LibraryHelper` (`using PCB;`).

The new component is named PCBComponent_1. When the library already has a component of that name, the name gets " - duplicate" appended, then a number that is increased until the name is unique.

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

### DeRegisterComponent

De-registers a component from the library, so that the library no longer recognizes it.

```csharp
bool DeRegisterComponent(IPCB_LibComponent argComponent);
bool DeRegisterComponent(object argComponent);
```

| Parameter | Type | Passing |
| --- | --- | --- |
| `argComponent` | [IPCB_LibComponent](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibComponent.md) | value |

**Returns:** `bool`

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

Returns false, and does nothing, when the component is null or does not belong to this library. Otherwise the component is removed from the library's list and returns true; when it was the current component, the library has no current component afterwards. The component object itself is not destroyed (compare [`RemoveComponent`](#removecomponent)).

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

### GetComponent

Returns the component (footprint) at the given position in the library's component list.

```csharp
IPCB_LibComponent GetComponent(int argI);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argI` | `int` | value | The zero-based position of the component, from 0 to [`ComponentCount`](#componentcount) - 1. |

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

Extension method of `IPCB_LibraryHelper` (`using PCB;`).

### GetComponentByName

Returns the component (footprint) with the given name, or null when the library has no component of that name.

```csharp
IPCB_LibComponent GetComponentByName(string argCompName);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argCompName` | `string` | value | The name of the component to find. |

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

Extension method of `IPCB_LibraryHelper` (`using PCB;`).

The name is compared with each component's [`IPCB_LibComponent.Pattern`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibComponent.md#pattern), ignoring case.

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

### GetUniqueCompName

Returns a component name that is not yet used in the library, based on the given name.

```csharp
string GetUniqueCompName(string argTestCompName);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argTestCompName` | `string` | value | The proposed component name. |

**Returns:** `string`

When no component has the given name, the name is returned unchanged. Otherwise " - duplicate" is appended; when that name is taken too, a number is appended and increased until the name is unique. Names are compared ignoring case.

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

### HasServerDocument

Returns whether the library has a `Board` and that board is attached to a server document.

```csharp
bool HasServerDocument();
```

**Returns:** `bool`

### LibraryIterator_Create

Creates an iterator that fetches the footprints ([`IPCB_LibComponent`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibComponent.md)) of the library.

```csharp
IPCB_LibraryIterator LibraryIterator_Create();
```

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

Extension method of `IPCB_LibraryHelper` (`using PCB;`).

Destroy the iterator with [`LibraryIterator_Destroy`](#libraryiterator_destroy) when you no longer need it.

**See also:** [IPCB_LibraryIterator](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibraryIterator.md), [IPCB_LibComponent](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibComponent.md)

**Examples:** [Extension_PcbLibComponentToSTEP](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Extension_PcbLibComponentToSTEP/Source%20Code/Commands.cs#L37), [Extension_PcbLibToImage](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Extension_PcbLibToImage/Source%20Code/Commands.cs#L43)

### LibraryIterator_Destroy

Destroys a library iterator created by [`LibraryIterator_Create`](#libraryiterator_create).

```csharp
void LibraryIterator_Destroy(ref IPCB_LibraryIterator argIterator);
void LibraryIterator_Destroy(ref object argIterator);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argIterator` | [IPCB_LibraryIterator](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibraryIterator.md) | ref | The iterator created by [`LibraryIterator_Create`](#libraryiterator_create); set to null on return. |

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

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

**See also:** [IPCB_LibComponent](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibComponent.md), [IPCB_LibraryIterator](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibraryIterator.md)

**Examples:** [Extension_PcbLibComponentToSTEP](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Extension_PcbLibComponentToSTEP/Source%20Code/Commands.cs#L60), [Extension_PcbLibToImage](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Extension_PcbLibToImage/Source%20Code/Commands.cs#L67)

### LibraryLoaderSaver_Create

Creates a library loader-saver ([`IPCB_LibraryLoaderSaver`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibraryLoaderSaver.md)).

```csharp
IPCB_LibraryLoaderSaver LibraryLoaderSaver_Create();
```

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

Extension method of `IPCB_LibraryHelper` (`using PCB;`).

Destroy it with [`LibraryLoaderSaver_Destroy`](#libraryloadersaver_destroy) when you no longer need it.

### LibraryLoaderSaver_Destroy

Destroys a library loader-saver created by [`LibraryLoaderSaver_Create`](#libraryloadersaver_create).

```csharp
void LibraryLoaderSaver_Destroy(ref IPCB_LibraryLoaderSaver argLoaderSaver);
void LibraryLoaderSaver_Destroy(ref object argLoaderSaver);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argLoaderSaver` | [IPCB_LibraryLoaderSaver](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibraryLoaderSaver.md) | ref | The loader-saver to destroy; set to null on return. |

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

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

### LinkDocumentToReleaseVault

Links the library document to a vault folder and item, and returns whether this succeeded.

```csharp
bool LinkDocumentToReleaseVault(string argParameters, ref string argErrorMsg);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argParameters` | `string` | value | The parameter string with the vault link settings. |
| `argErrorMsg` | `string` | ref | Receives an error message when a required GUID is missing; empty otherwise. |

**Returns:** `bool`

The method acts only when the parameters set RunSilent to True; otherwise it does nothing and returns false. The parameters must then give the vault, folder, item and revision GUIDs; when one is missing, the method returns false with an error message. On success the library's [`VaultGUID`](#vaultguid) and [`FolderGUID`](#folderguid) take the given values and its [`LifeCycleDefinitionGUID`](#lifecycledefinitionguid) and [`RevisionNamingSchemeGUID`](#revisionnamingschemeguid) become empty; when the library has exactly one component, that component's [`IPCB_LibComponent.ItemGUID`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibComponent.md#itemguid) and [`IPCB_LibComponent.ItemRevisionGUID`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibComponent.md#itemrevisionguid) take the given item and revision GUIDs.

### Navigate_FirstComponent

Navigates to the first component of the library and sets the focus to it.

```csharp
void Navigate_FirstComponent();
```

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

Uses the library editor's navigation panel; does nothing when the library has no editor window with that panel.

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

### RefreshView

Does nothing.

```csharp
void RefreshView();
```

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

### RegisterComponent

Registers a new footprint in the library.

```csharp
bool RegisterComponent(IPCB_LibComponent argComponent);
bool RegisterComponent(object argComponent);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argComponent` | [IPCB_LibComponent](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibComponent.md) | value | The component to add to the library. |

**Returns:** `bool`

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

Returns false, and does nothing, when the component is null, its name ([`IPCB_LibComponent.Pattern`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibComponent.md#pattern)) is empty, or the library already has a component of that name (compared ignoring case); use [`GetUniqueCompName`](#getuniquecompname) to get a free name. Otherwise the component is added to the library, belongs to it from then on, and the method returns true. Registering does not make the component current.

When creating a new footprint programmatically, for example with [`IPCB_ServerInterface.CreatePCBLibComp`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ServerInterface.md#createpcblibcomp), register it before making it the current component ([`CurrentComponent`](#currentcomponent) or [`SetBoardToComponentByName`](#setboardtocomponentbyname)).

**Example:** Add a new footprint to the current PCB library and make it the current one.

```csharp
using PCB;

IPCB_ServerInterface pcbServer = PCB.GlobalVars.PCBServer;
if (pcbServer == null)
    return;
IPCB_Library currentLib = pcbServer.GetCurrentPCBLibrary();
if (currentLib == null)
    return;
IPCB_LibComponent newPCBLibComp = pcbServer.CreatePCBLibComp();
newPCBLibComp.SetState_Pattern("ANewComponent");
currentLib.RegisterComponent(newPCBLibComp);
currentLib.SetState_CurrentComponent(newPCBLibComp);
```

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

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

### ReleaseDocument

Releases the library document to the vault, and returns whether the release succeeded.

```csharp
bool ReleaseDocument(string argParameters, ref string argErrorMsg);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argParameters` | `string` | value |  |
| `argErrorMsg` | `string` | ref | Set to an empty string. |

**Returns:** `bool`

### RemoveComponent

Removes a component from the library.

```csharp
void RemoveComponent(ref IPCB_LibComponent argComponent);
void RemoveComponent(ref object argComponent);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argComponent` | [IPCB_LibComponent](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibComponent.md) | ref | The component to remove; set to null on return. |

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

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

Does nothing when the component does not belong to this library. Otherwise the component is removed from the library editor's component list (when the editor is open) and from the library, and is destroyed; when it was the current component, the library has no current component afterwards. To remove a component from the library without destroying it, use [`DeRegisterComponent`](#deregistercomponent).

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

### SaveComponentWithLibrary

Saves one component of the library to a new PCB library file, and returns whether this succeeded.

```csharp
bool SaveComponentWithLibrary(string argComponentName, string argFileName);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argComponentName` | `string` | value | The name ([`IPCB_LibComponent.Pattern`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibComponent.md#pattern)) of the component to save. |
| `argFileName` | `string` | value | The full path of the PCB library file to write. |

**Returns:** `bool`

The file contains the library's settings and only the named component; the library itself is not changed. Missing folders of the path are created. Returns false when the library has no component of that name (compared ignoring case), when the folder cannot be created, or when saving fails.

### SaveEmptyLibrary

Saves a PCB library file that has the library's settings and no components, and returns whether this succeeded.

```csharp
bool SaveEmptyLibrary(string argFileName);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argFileName` | `string` | value | The full path of the PCB library file to write. |

**Returns:** `bool`

Missing folders of the path are created. Returns false when the folder cannot be created or saving fails.

### SetBoardToComponentByName

Makes the component with the given name the current component, and returns whether this succeeded.

```csharp
bool SetBoardToComponentByName(string argCompName);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argCompName` | `string` | value | The name ([`IPCB_LibComponent.Pattern`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibComponent.md#pattern)) of the component to make current. |

**Returns:** `bool`

The primitives of the previous current component are moved off the library's `Board` and the primitives of the named component onto it. Returns false, and does nothing, when the library has no component of that name (compared ignoring case, as in [`GetComponentByName`](#getcomponentbyname)).

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

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

### SetCurrentComponentReference

Sets the origin of the library's board, the reference point of the component in focus.

```csharp
void SetCurrentComponentReference(int argX, int argY);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argX` | `int` | value | The X coordinate of the origin, in internal units (10,000 per mil). |
| `argY` | `int` | value | The Y coordinate of the origin, in internal units (10,000 per mil). |

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

The method assigns the coordinates to [`IPCB_Board.XOrigin`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Board.md#xorigin) and [`IPCB_Board.YOrigin`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Board.md#yorigin) of the library's `Board`; it does not move the component's primitives.

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

### SplitIntoComponents

Saves each component of the library to its own PCB library file in a folder.

```csharp
void SplitIntoComponents(string argOutputDirectoryPath, bool argOverwriteExistingFile, bool argRemoveBadCharactersFromName);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argOutputDirectoryPath` | `string` | value | The folder to write the files to. |
| `argOverwriteExistingFile` | `bool` | value | True to overwrite existing files of the same name; false to give the new file a different, unused name instead. |
| `argRemoveBadCharactersFromName` | `bool` | value | True to also remove characters that are not allowed in file names from the component's name inside the new library; false to keep the name. |

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

Each file is named after the component's [`IPCB_LibComponent.Pattern`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibComponent.md#pattern), with characters that are not allowed in file names removed, and has the extension .PcbLib. The vault GUIDs of the library ([`VaultGUID`](#vaultguid), [`FolderGUID`](#folderguid), [`LifeCycleDefinitionGUID`](#lifecycledefinitionguid), [`RevisionNamingSchemeGUID`](#revisionnamingschemeguid)) are copied to the new libraries. The library itself is not changed.

## Returned by

[IPCB_ServerInterface.CreatePCBLibrary](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ServerInterface.md#createpcblibrary), [IPCB_ServerInterface.GetCurrentPCBLibrary](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ServerInterface.md#getcurrentpcblibrary), [IPCB_ServerInterface.GetPCBLibraryByLibraryID](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ServerInterface.md#getpcblibrarybylibraryid), [IPCB_ServerInterface.GetPCBLibraryByPath](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ServerInterface.md#getpcblibrarybypath), [IPCB_ServerInterface.LoadPCBLibraryByPath](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ServerInterface.md#loadpcblibrarybypath), [IPCB_ServerInterface.LoadPCBLibraryFromFile](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ServerInterface.md#loadpcblibraryfromfile)

## Accepted by

[IPCB_LibraryLoaderSaver.LoadFromFile](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibraryLoaderSaver.md#loadfromfile), [IPCB_LibraryLoaderSaver.SaveToFile](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibraryLoaderSaver.md#savetofile), [IPCB_ServerInterface.DestroyPCBLibrary](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ServerInterface.md#destroypcblibrary)

## Examples

Used in the SDK examples: [Extension_CreatePCBLib](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Extension_CreatePCBLib/Source%20Code/Commands.cs#L39), [Extension_PcbLibComponentToSTEP](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Extension_PcbLibComponentToSTEP/Source%20Code/Commands.cs#L33), [Extension_PcbLibToImage](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Extension_PcbLibToImage/Source%20Code/Commands.cs#L39).
