IComponentInfo interface
The IComponentInfo interface is an item within the ILibCompInfoReader interface. This IComponentInfo interface represents a schematic symbol in a specified schematic library file with a SchLib extension.
public interface IComponentInfo
Namespace: SCH · Assembly: Altium.SDK.Interfaces
Derived: IComponentFullInfo
Remarks
The steps required to load a schematic library and its components.
-
Create an object and pass in the filename of a schematic library file. This object is represented by the
ILibCompInfoReaderinterface byISch_ServerInterface.CreateLibCompInfoReader. -
Invoke the
ILibCompInfoReader.ReadAllComponentInfomethod to load the library and its components. -
Invoke the
ILibCompInfoReader.NumComponentInfosmethod to obtain the number of components for this library -
Obtain the indexed ComponentInfos method. This ComponentInfos method returns the indexed
IComponentInfointerface.
The IComponentInfo interface is extracted from the ILibCompInfoReader.ComponentInfos method.
Example
List the name, alias, part count, description and offset of each component in a schematic library.
using System.Collections.Generic;
using System.IO;
using DXP;
using SCH;
ISch_ServerInterface schServer = SCH.GlobalVars.SchServer;
ISch_Document currentLib = schServer?.GetCurrentSchDocument();
if (currentLib == null)
return;
string fileName = currentLib.GetState_DocumentName();
ILibCompInfoReader aLibCompReader = schServer.CreateLibCompInfoReader(fileName);
aLibCompReader.ReadAllComponentInfo();
var reportInfo = new List<string>();
// Obtain the number of components in the specified schematic library.
int compNum = aLibCompReader.NumComponentInfos();
// Go through each component obtained by the library component reader.
for (int j = 0; j < compNum; j++)
{
reportInfo.Add(fileName);
IComponentInfo compInfo = aLibCompReader.GetState_ComponentInfo(j);
reportInfo.Add(" Name : " + compInfo.GetState_CompName());
reportInfo.Add(" Alias Name : " + compInfo.GetState_AliasName());
reportInfo.Add(" Part Count : " + compInfo.GetState_PartCount());
reportInfo.Add(" Description : " + compInfo.GetState_Description());
reportInfo.Add(" Offset : " + compInfo.GetState_Offset());
reportInfo.Add("");
}
string reportPath = Path.Combine(Path.GetTempPath(), "SchLibCompReport.txt");
File.WriteAllLines(reportPath, reportInfo);
IClient client = DXP.GlobalVars.Client;
IServerDocument reportDocument = client.OpenDocument("Text", reportPath);
if (reportDocument != null)
client.ShowDocument(reportDocument);
Properties
| Property | Type | Access | Description |
|---|---|---|---|
| AliasName | string | get | This property returns the alias name for this component. |
| CompName | string | get | This property returns the name string for this component from the IComponentInfo object interface. |
| Description | string | get | This property returns the description string for this component from the IComponentInfo object interface. |
| Offset | int | get | This property returns the offset as a number – each part of a component whole has an offset to denote its place within the component. |
| PartCount | int | get | This method obtains the number of parts (multiple types of the same component type as an example). |
AliasName
This property returns the alias name for this component. Ie a component can be referred to by one of its multiple names.
string GetState_AliasName();
Type: string · Access: read-only
CompName
This property returns the name string for this component from the IComponentInfo object interface.
string GetState_CompName();
Type: string · Access: read-only
Description
This property returns the description string for this component from the IComponentInfo object interface.
string GetState_Description();
Type: string · Access: read-only
Offset
This property returns the offset as a number – each part of a component whole has an offset to denote its place within the component.
int GetState_Offset();
Type: int · Access: read-only
PartCount
This method obtains the number of parts (multiple types of the same component type as an example). For example an Integrated circuit may have multiple smaller modules, such as a 74LS00 has multiple OR gates.
int GetState_PartCount();
Type: int · Access: read-only
Methods
| Method | Returns | Description |
|---|---|---|
| GetPartName | string |
GetPartName
No description yet.
string GetPartName(int argPartNumber);
| Parameter | Type | Passing |
|---|---|---|
argPartNumber | int | value |
Returns: string