Skip to main content
View as Markdown

IPCB_LibComponent interface

A footprint (library component) in a PCB library document.

public interface IPCB_LibComponent : IPCB_Group

Namespace: PCB · Assembly: Altium.SDK.Interfaces

Inherits: IPCB_Primitive → IPCB_Group

Remarks​

A PCB library document holds a list of footprints, the "pages" of the library, and each of them is represented by an IPCB_LibComponent. Get them from the IPCB_Library: with IPCB_Library.GetComponent, IPCB_Library.GetComponentByName, or with an IPCB_LibraryIterator created by IPCB_Library.LibraryIterator_Create and released by IPCB_Library.LibraryIterator_Destroy. The footprint in focus in the library editor is IPCB_Library.CurrentComponent.

IPCB_LibComponent is derived from IPCB_Group. A footprint is composed of child objects such as pads and tracks, which you fetch with the footprint's own IPCB_GroupIterator.

The primitives of the current footprint are placed on the library's board (IPCB_Library.Board) for display and editing; TransferAllPrimitivesOntoBoard and TransferAllPrimitivesBackFromBoard move them between the footprint and that board.

Example​

Write the name, height and description of every footprint in the current PCB library to a CSV report.

using System.Collections.Generic;
using System.IO;
using DXP;
using PCB;

IPCB_Library currentLib = PCB.GlobalVars.PCBServer?.GetCurrentPCBLibrary();
if (currentLib == null)
return;

string fileName = Path.Combine(Path.GetDirectoryName(currentLib.GetState_Board().GetState_FileName()), "PCBLib_Report.csv");
string s = "";
var footprintList = new List<string>();
IPCB_LibraryIterator footprintIterator = currentLib.LibraryIterator_Create();
footprintIterator.SetState_FilterAll();
try
{
var footprint = footprintIterator.FirstPCBObject() as IPCB_LibComponent;
while (footprint != null)
{
// The height is reported in mils when the display unit is metric,
// and in millimeters otherwise.
if (currentLib.GetState_Board().GetState_DisplayUnit() == TUnit.eMetric)
s = footprint.GetState_Pattern()
+ ","
+ EDP.Utils.CoordToMils(footprint.GetState_Height())
+ ","
+ footprint.GetState_Description();
else
s = footprint.GetState_Pattern()
+ ","
+ EDP.Utils.CoordToMMs(footprint.GetState_Height())
+ ","
+ footprint.GetState_Description();
footprintList.Add(s);
footprint = footprintIterator.NextPCBObject() as IPCB_LibComponent;
}
}
finally
{
currentLib.LibraryIterator_Destroy(ref footprintIterator);
File.WriteAllLines(fileName, footprintList);
}

// Display the saved report.
IClient client = DXP.GlobalVars.Client;
IServerDocument reportDocument = client.OpenDocument("Text", fileName);
if (reportDocument != null)
client.ShowDocument(reportDocument);

Properties​

PropertyTypeAccessDescription
Descriptionstringget; setThe description of the footprint.
Heightintget; setThe height of the footprint, in internal units (10,000 per mil).
ItemGUIDstringget; setThe GUID of the server Item that the footprint is linked to for release.
ItemRevisionGUIDstringget; setThe GUID of the Item revision that the footprint is linked to for release.
Patternstringget; setThe name (pattern) of the footprint.

Description​

The description of the footprint.

string GetState_Description();
void SetState_Description(string argValue);

Type: string · Access: read/write

Height​

The height of the footprint, in internal units (10,000 per mil).

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

Type: int · Access: read/write

ItemGUID​

The GUID of the server Item that the footprint is linked to for release.

string GetState_ItemGUID();
void SetState_ItemGUID(string argValue);

Type: string · Access: read/write

ItemRevisionGUID​

The GUID of the Item revision that the footprint is linked to for release.

string GetState_ItemRevisionGUID();
void SetState_ItemRevisionGUID(string argValue);

Type: string · Access: read/write

Pattern​

The name (pattern) of the footprint.

string GetState_Pattern();
void SetState_Pattern(string argValue);

Type: string · Access: read/write

Leading and trailing spaces are removed from an assigned value.

Examples: Extension_CreatePCBLib, Extension_PcbLibComponentToSTEP, Extension_PcbLibToImage

Methods​

MethodReturnsDescription
CopyTovoidCopies the footprint's primitives and properties into another footprint.
ReleasableInterfaceobject
SaveModelToFileboolExports the 3D models of the footprint's 3D bodies to a file.
SaveToFilevoidSaves the footprint on its own to a PCB library file.
TransferAllPrimitivesBackFromBoardvoidMoves the primitives on the library's board into the footprint; the reverse of TransferAllPrimitivesOntoBoard.
TransferAllPrimitivesOntoBoardvoidPlaces the footprint's primitives on the library's board, where they are displayed and edited.

CopyTo​

Copies the footprint's primitives and properties into another footprint.

void CopyTo(IPCB_LibComponent argP, TCopyMode argCopyMode);
void CopyTo(object argP, int argCopyMode);
ParameterTypePassingDescription
argPIPCB_LibComponentvalueThe footprint to copy into.
argCopyModeTCopyModevalueThe copy mode used to replicate each primitive.

Returns: nothing (void)

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

Each child primitive of this footprint is replicated with the given copy mode and added to the target footprint. The description, height, ItemGUID and ItemRevisionGUID are copied to the target as well.

ReleasableInterface​

No description yet.

object ReleasableInterface();

Returns: object

SaveModelToFile​

Exports the 3D models of the footprint's 3D bodies to a file.

bool SaveModelToFile(string argFilename, bool argSaveAsPart);
ParameterTypePassingDescription
argFilenamestringvalueThe path of the file to write.
argSaveAsPartboolvaluefalse exports the models to a STEP file; true saves them as a part.

Returns: bool

The models are positioned relative to the footprint's location. Nothing is written when none of the footprint's 3D bodies has a model. The returned value is not set and does not indicate whether a file was written.

SaveToFile​

Saves the footprint on its own to a PCB library file.

void SaveToFile(string argVFSAddress);
ParameterTypePassingDescription
argVFSAddressstringvalueThe path of the PCB library file to write.

Returns: nothing (void)

The file holds a library that contains only this footprint. When the footprint is the current footprint of its library, its primitives are taken back from the library's board for the save and placed on the board again afterwards.

TransferAllPrimitivesBackFromBoard​

Moves the primitives on the library's board into the footprint; the reverse of TransferAllPrimitivesOntoBoard.

void TransferAllPrimitivesBackFromBoard();

Returns: nothing (void)

The primitives on the board, on all layers, become child objects of the footprint and are deselected. They are moved by the negative of the board origin, so that the footprint's coordinates are relative to the board origin.

TransferAllPrimitivesOntoBoard​

Places the footprint's primitives on the library's board, where they are displayed and edited.

void TransferAllPrimitivesOntoBoard();

Returns: nothing (void)

The primitives are moved by 50,000 mils in X and Y, and the board origin is set to that point, so that the footprint's coordinates are relative to the board origin.

Inherited members​

Returned by​

IPCB_Library.AddComponent, IPCB_Library.CreateNewComponent, IPCB_Library.CurrentComponent, IPCB_Library.GetComponent, IPCB_Library.GetComponentByName, IPCB_ServerInterface.CreatePCBLibComp, IPCB_ServerInterface.LoadCompFromLibrary

Accepted by​

IPCB_ComponentPainterView.SetComponentByHandle_1, IPCB_Library.DeRegisterComponent, IPCB_Library.RegisterComponent, IPCB_Library.RemoveComponent, IPCB_ServerInterface.DestroyPCBLibComp

Examples​

Used in the SDK examples: Extension_CreatePCBLib, Extension_PcbLibComponentToSTEP, Extension_PcbLibToImage.