Skip to main content
View as Markdown

IPCB_ObjectClass interface

A class on a PCB document, a named group of objects of one kind, such as nets or components, identified by its unique class name.

public interface IPCB_ObjectClass : IPCB_Primitive

Namespace: PCB · Assembly: Altium.SDK.Interfaces

Inherits: IPCB_Primitive

Derived: IPCB_ObjectClass2

Remarks​

An object can belong to more than one class. MemberKind sets the kind of object the class holds: nets, components, from-tos, pads, layers, design channels, differential pairs, polygons, split planes, classes, xSignals or xNets. The members are stored as names (for example a net name or a component designator), not as references to the objects.

An ObjectClass object can be created with the IPCB_ServerInterface.PCBClassFactoryByClassMember or IPCB_ServerInterface.PCBObjectFactory method.

A class created with IPCB_ServerInterface.PCBClassFactoryByClassMember for TClassMemberKind.eClassMemberKind_ObjectClass or TClassMemberKind.eClassMemberKind_xNetClass holds other classes. Members are added to such a class with AddMember; AddMemberByName does nothing, IsMember returns false and MemberName returns an empty string.

Properties​

PropertyTypeAccessDescription
MemberKindTClassMemberKindget; setThe kind of object the class holds.
MemberNamestringgetThe name of a member of the class.
Namestringget; setThe name of the class.
SuperClassboolget; setWhether the class implicitly contains all objects of its member kind, such as the "All Nets" class.

MemberKind​

The kind of object the class holds.

TClassMemberKind GetState_MemberKind();
void SetState_MemberKind(TClassMemberKind argValue);

Type: TClassMemberKind · Access: read/write

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

The kind decides which objects IsValidObjectKind accepts, and therefore what AddMember and RemoveMember do, and whether AddLayerMember and RemoveLayerMember have an effect. To find the classes of one kind on a board, iterate the board's TObjectId.eClassObject objects on TV6_Layer.eV6_MultiLayer and test MemberKind.

See also: TClassMemberKind

MemberName​

The name of a member of the class.

string GetState_MemberName(int argI);

Type: string · Access: read-only · Index: argI (int): The zero-based index of the member.

Returns an empty string when the index is outside the member list, and for a class that holds other classes.

Name​

The name of the class.

string GetState_Name();
void SetState_Name(string argValue);

Type: string · Access: read/write

For a class, Identifier returns the same value as Name.

SuperClass​

Whether the class implicitly contains all objects of its member kind, such as the "All Nets" class.

bool GetState_SuperClass();
void SetState_SuperClass(bool argValue);

Type: bool · Access: read/write

While SuperClass is true, IsMember returns true for every name (with the exceptions listed there), and IsLayerMember decides from the class name instead of the stored members. The stored members are kept and can still be changed; they are ignored by these checks.

Example: Report which object classes on the current board are super classes.

using System.Collections.Generic;
using PCB;

IPCB_Board board = PCB.GlobalVars.PCBServer?.GetCurrentPCBBoard();
if (board == null)
return;

var report = new List<string>();
IPCB_BoardIterator iterator = board.BoardIterator_Create();
iterator.AddFilter_ObjectSet(new PCB.TObjectSet { TObjectId.eClassObject });
iterator.AddFilter_AllLayers();
iterator.AddFilter_Method(TIterationMethod.eProcessAll);
for (var objectClass = iterator.FirstPCBObject() as IPCB_ObjectClass; objectClass != null; objectClass = iterator.NextPCBObject() as IPCB_ObjectClass)
{
if (objectClass.GetState_SuperClass())
{
// This is a super class.
switch (objectClass.GetState_MemberKind())
{
case TClassMemberKind.eClassMemberKind_Net: report.Add("All Nets"); break;
case TClassMemberKind.eClassMemberKind_Component: report.Add("All Components"); break;
case TClassMemberKind.eClassMemberKind_FromTo: report.Add("All FromTos"); break;
case TClassMemberKind.eClassMemberKind_Pad: report.Add("All Pads"); break;
case TClassMemberKind.eClassMemberKind_Layer: report.Add("All Layers"); break;
}
}
}
board.BoardIterator_Destroy(ref iterator);

DXP.Utils.ShowInfo(string.Join("\r\n", report), "Super Classes");

See also: TClassMemberKind

Methods​

MethodReturnsDescription
AddLayerMembervoidAdds a layer to a layer class.
AddMembervoidAdds a design object to the class.
AddMemberByNamevoidAdds a member to the class by its name, such as a net name or a component designator.
IsLayerMemberboolReturns whether a layer belongs to a layer class.
IsMemberboolReturns whether a name, such as a net name or a component designator, is a member of the class.
IsValidObjectKindboolReturns whether a design object is of the kind this class holds, as set by MemberKind.
RemoveAllMembersvoidRemoves all the members of the class.
RemoveLayerMembervoidRemoves a layer from a layer class.
RemoveMembervoidRemoves a design object from the class.

AddLayerMember​

Adds a layer to a layer class.

void AddLayerMember(TV6_Layer argL);
void AddLayerMember(int argL);
ParameterTypePassing
argLTV6_Layervalue

Returns: nothing (void)

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

The layer is stored as a member name. The call does nothing unless MemberKind is TClassMemberKind.eClassMemberKind_Layer.

AddMember​

Adds a design object to the class.

void AddMember(IPCB_Primitive argP);
void AddMember(object argP);
ParameterTypePassing
argPIPCB_Primitivevalue

Returns: nothing (void)

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

The object's Identifier is stored as a member name. The call does nothing when the object is null or when IsValidObjectKind returns false for it, so set MemberKind before adding members. A class that holds other classes cannot be added to itself.

AddMemberByName​

Adds a member to the class by its name, such as a net name or a component designator.

void AddMemberByName(string argName);
ParameterTypePassing
argNamestringvalue

Returns: nothing (void)

The name is not checked against the objects on the board, and a name that is already a member is added again. IsMember compares names case-sensitively, so the name must match the object's name exactly.

Example: Create a net class that contains the GND net on the current board.

using PCB;

IPCB_ServerInterface pcbServer = PCB.GlobalVars.PCBServer;
IPCB_Board board = pcbServer?.GetCurrentPCBBoard();
if (board == null)
return;

pcbServer.PreProcess();
IPCB_ObjectClass netClass = pcbServer.PCBClassFactoryByClassMember(TClassMemberKind.eClassMemberKind_Net);
netClass.SetState_SuperClass(false);
netClass.SetState_Name("NetGndClass");
netClass.AddMemberByName("GND");
board.AddPCBObject(netClass);
pcbServer.PostProcess();

IsLayerMember​

Returns whether a layer belongs to a layer class.

bool IsLayerMember(TV6_Layer argL);
bool IsLayerMember(int argL);
ParameterTypePassing
argLTV6_Layervalue

Returns: bool

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

For a super class (SuperClass is true) the result depends on Name: the class "All Layers" contains every layer, the classes "Electrical Layers", "Signal Layers" and "Component Layers" contain the electrical, signal and component layers, and for any other name the result is false. For any other class the result is true when the layer was added with AddLayerMember.

IsMember​

Returns whether a name, such as a net name or a component designator, is a member of the class.

bool IsMember(string argS);
ParameterTypePassing
argSstringvalue

Returns: bool

For a super class (SuperClass is true) the result is true for every name. Otherwise the name is compared with the stored member names; the comparison is case-sensitive. Automatically generated component classes, such as the classes of the components on the top or the bottom side, are an exception: they decide membership from the component on the board instead. The SDK examples test whether an xSignal belongs to a class of kind TClassMemberKind.eClassMemberKind_Signal by passing the pin pair's IPCB_PinPair.Name.

IsValidObjectKind​

Returns whether a design object is of the kind this class holds, as set by MemberKind.

bool IsValidObjectKind(IPCB_Primitive argP);
bool IsValidObjectKind(object argP);
ParameterTypePassing
argPIPCB_Primitivevalue

Returns: bool

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

Returns false for null. Nets are accepted by a class of nets or xNets, components, from-tos, pads, differential pairs and polygons by a class of that kind, pin pairs by a class of xSignals, and component classes by a class of design channels. A class of layers or split planes accepts no object; layers are added with AddLayerMember. A class that holds other classes accepts any class object. AddMember and RemoveMember use this check.

RemoveAllMembers​

Removes all the members of the class.

void RemoveAllMembers();

Returns: nothing (void)

Name, MemberKind and SuperClass do not change.

RemoveLayerMember​

Removes a layer from a layer class.

void RemoveLayerMember(TV6_Layer argL);
void RemoveLayerMember(int argL);
ParameterTypePassing
argLTV6_Layervalue

Returns: nothing (void)

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

The call does nothing unless MemberKind is TClassMemberKind.eClassMemberKind_Layer.

RemoveMember​

Removes a design object from the class.

void RemoveMember(IPCB_Primitive argP);
void RemoveMember(object argP);
ParameterTypePassing
argPIPCB_Primitivevalue

Returns: nothing (void)

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

The object's Identifier is removed from the member names. The call does nothing when the object is null or when IsValidObjectKind returns false for it.

Inherited members​

Returned by​

IPCB_ServerInterface.PCBClassFactory, IPCB_ServerInterface.PCBClassFactoryByClassMember

Accepted by​

IPCB_Board.ClassNameIsUnique