Skip to main content
View as Markdown

IPCB_Rule interface

A design rule on a PCB document; the base interface of the PCB design rule and constraint interfaces.

public interface IPCB_Rule : IPCB_Primitive

Namespace: PCB · Assembly: Altium.SDK.Interfaces

Inherits: IPCB_Primitive

Derived: IPCB_AcuteAngle, IPCB_BoardOutlineClearanceConstraint, IPCB_BrokenNetRule, IPCB_CheckNetAntennaeRule, IPCB_ClearanceConstraint, IPCB_ComponentClearanceConstraint, IPCB_ComponentRotationsRule, IPCB_ConfinementConstraint, IPCB_DaisyChainStubLengthConstraint, IPCB_DifferentialPairsRoutingRule, IPCB_FanoutControlRule, IPCB_HoleToHoleClearanceRule, IPCB_LayerPairsRule, IPCB_MatchedNetLengthsConstraint, IPCB_MaxMinHeightConstraint, IPCB_MaxMinHoleSizeConstraint, IPCB_MaxMinLengthConstraint, IPCB_MaxMinWidthConstraint, IPCB_MaxOvershootFall, IPCB_MaxOvershootRise, IPCB_MaxUndershootFall, IPCB_MaxUndershootRise, IPCB_MaximumViaCountRule, IPCB_MinimumAnnularRing, IPCB_MinimumSolderMaskSliverRule, IPCB_ModifiedPolygonRule, IPCB_NetsToIgnoreRule, IPCB_ParallelSegmentConstraint, IPCB_PasteMaskExpansionRule, IPCB_PermittedLayersRule, IPCB_PolygonConnectStyleRule, IPCB_PowerPlaneClearanceRule, IPCB_PowerPlaneConnectStyleRule, IPCB_RoutingCornerStyleRule, IPCB_RoutingLayersRule, IPCB_RoutingPriorityRule, IPCB_RoutingTopologyRule, IPCB_RoutingViaStyleRule, IPCB_RuleFlightTime_FallingEdge, IPCB_RuleFlightTime_RisingEdge, IPCB_RuleMaxMinImpedance, IPCB_RuleMaxSignalBaseValue, IPCB_RuleMaxSlopeFallingEdge, IPCB_RuleMaxSlopeRisingEdge, IPCB_RuleMinSignalTopValue, IPCB_RuleSupplyNets, IPCB_SMDNeckDownConstraint, IPCB_SMDPADEntryConstraint, IPCB_SMDToCornerConstraint, IPCB_SMDToPlaneConstraint, IPCB_ShortCircuitConstraint, IPCB_SignalStimulus, IPCB_SilkToSilkClearanceRule, IPCB_SilkToSolderMaskClearanceRule, IPCB_SolderMaskExpansionRule, IPCB_TestPointStyleRule, IPCB_TestPointUsage, IPCB_UnConnectedPinRule, IPCB_ViasUnderSMDConstraint

Remarks​

Design rules cover clearances, object geometry, impedance control, routing priority, routing topology and parallelism, among others.

The scope of a rule is the set of objects that the rule applies to. It is defined by one scope expression for a rule that applies to single objects, or by two scope expressions for a rule that applies to pairs of objects.

A rule is a PCB object: its ObjectID is TObjectId.eRuleObject, so the rules of a board are found by iterating the board with an object filter for TObjectId.eRuleObject. A new rule is created with IPCB_ServerInterface.PCBRuleFactory for a TRuleKind and added to the board with IPCB_Board.AddPCBObject.

This interface has what all rules share: name, comment, kind, scope and whether the rule is checked. The constraint values are on the interface of the rule kind, for example IPCB_ClearanceConstraint or IPCB_MaxMinHoleSizeConstraint; cast the rule to that interface to read or change them.

Properties​

PropertyTypeAccessDescription
CollisionExpansionintgetThe rule's collision expansion distance, in internal units (10,000 per mil).
Commentstringget; setA free-text comment on the rule.
DataSummaryStringstringgetA short text that lists the rule's constraint values.
DefinedByLogicalDocumentboolget; setWhether the rule comes from the rule definitions of the design's logical (schematic) documents.
DRCEnabledboolget; setWhether the rule is checked by design rule checking.
LayerKindTRuleLayerKindget; setWhether the rule tests objects on the same layer or on adjacent layers.
Namestringget; setThe name of the rule.
NetScopeTNetScopeget; setWhich net relationship a pair of objects must have for the rule to apply to them.
RuleKindTRuleKindget; setThe kind of design rule, for example TRuleKind.eRule_Clearance.
Scope1Expressionstringget; setThe query expression that selects the objects of the rule's first scope, for example All.
Scope2Expressionstringget; setThe query expression that selects the objects of the rule's second scope, for rule kinds that apply to pairs of objects.
ScopeDescriptorStringstringgetA text that shows the rule's scope expressions.
ShortDescriptorStringstringgetThe display name of the rule kind, for example Clearance Constraint for a clearance rule.
ViolationDescriptorStringstringgetA text that describes the given violation of this rule.

CollisionExpansion​

The rule's collision expansion distance, in internal units (10,000 per mil).

int GetState_CollisionExpansion();

Type: int · Access: read-only

It is 0 for rule kinds that do not define one. For a clearance rule it is the gap, or the largest clearance of the rule when it defines clearances per object kind.

Comment​

A free-text comment on the rule.

string GetState_Comment();
void SetState_Comment(string argValue);

Type: string · Access: read/write

A new rule has an empty comment.

DataSummaryString​

A short text that lists the rule's constraint values.

string GetState_DataSummaryString();

Type: string · Access: read-only

The text depends on the rule kind: for example, a width rule lists its preferred, minimum and maximum width, and a short-circuit rule states whether short circuits are allowed. Sizes are shown in the board's display unit (IPCB_Board.DisplayUnit).

DefinedByLogicalDocument​

Whether the rule comes from the rule definitions of the design's logical (schematic) documents.

bool GetState_DefinedByLogicalDocument();
void SetState_DefinedByLogicalDocument(bool argValue);

Type: bool · Access: read/write

It is set to true when an engineering change order from the design project adds or updates the rule on the board. The default is false.

DRCEnabled​

Whether the rule is checked by design rule checking.

bool GetState_DRCEnabled();
void SetState_DRCEnabled(bool argValue);

Type: bool · Access: read/write

A new rule is enabled. The value reads false when the rule belongs to a rule set that is disabled, even if the rule itself is enabled; assigning a value enables or disables the rule itself. While the value is false, Scope1Includes, Scope2Includes, CheckUnaryScope and CheckBinaryScope return false.

LayerKind​

Whether the rule tests objects on the same layer or on adjacent layers.

TRuleLayerKind GetState_LayerKind();
void SetState_LayerKind(TRuleLayerKind argValue);

Type: TRuleLayerKind · Access: read/write

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

Used by the parallel segment rule (TRuleKind.eRule_ParallelSegment). The default is TRuleLayerKind.eRuleLayerKind_SameLayer.

Name​

The name of the rule.

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

Type: string · Access: read/write

When the rule is added to a board, an empty name is replaced by a name derived from the rule kind (for example Clearance), and a name that another rule of the board already has gets a numeric suffix such as _1.

NetScope​

Which net relationship a pair of objects must have for the rule to apply to them.

TNetScope GetState_NetScope();
void SetState_NetScope(TNetScope argValue);

Type: TNetScope · Access: read/write

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

NetScopeMatches tests a pair of objects against it. The default is TNetScope.eNetScope_AnyNet; a clearance rule starts with TNetScope.eNetScope_DifferentNetsOnly.

RuleKind​

The kind of design rule, for example TRuleKind.eRule_Clearance.

TRuleKind GetState_RuleKind();
void SetState_RuleKind(TRuleKind argValue);

Type: TRuleKind · Access: read/write

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

Scope1Expression​

The query expression that selects the objects of the rule's first scope, for example All.

string GetState_Scope1Expression();
void SetState_Scope1Expression(string argValue);

Type: string · Access: read/write

Leading and trailing spaces are removed from an assigned value. Assigning a value that differs from the current one only in letter case leaves the expression unchanged.

Scope2Expression​

The query expression that selects the objects of the rule's second scope, for rule kinds that apply to pairs of objects.

string GetState_Scope2Expression();
void SetState_Scope2Expression(string argValue);

Type: string · Access: read/write

Leading and trailing spaces are removed from an assigned value. Assigning a value that differs from the current one only in letter case leaves the expression unchanged.

ScopeDescriptorString​

A text that shows the rule's scope expressions.

string GetState_ScopeDescriptorString();

Type: string · Access: read-only

The form is (<Scope1Expression>),(<Scope2Expression>) for rule kinds that apply to pairs of objects and (<Scope1Expression>) for the others. It starts with (Disabled) when DRCEnabled is false.

ShortDescriptorString​

The display name of the rule kind, for example Clearance Constraint for a clearance rule.

string GetState_ShortDescriptorString();

Type: string · Access: read-only

ViolationDescriptorString​

A text that describes the given violation of this rule.

string GetState_ViolationDescriptorString(IPCB_Violation argV);

Type: string · Access: read-only · Index: argV (IPCB_Violation): The violation to describe.

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

Returns an empty string for a null violation.

Methods​

MethodReturnsDescription
ActualCheckIPCB_ViolationChecks the given object, or pair of objects, against the rule and returns the first violation found.
ActualCheck_1boolChecks a pair of objects against the rule and adds every violation found to a list.
CheckBinaryScopeboolReturns whether a pair of objects is in the rule's scope, in either order.
CheckUnaryScopeboolReturns whether the given object is in the scope of a rule that applies to single objects.
Export_ToParameters_1voidWrites the rule's properties to a parameter string.
GetWhatsThisHelpStringstringReturns the help topic identifier of the rule kind, for example PCB_ClearanceRule_ for a clearance rule.
IsUnaryboolReturns whether the rule kind applies to single objects rather than to pairs of objects.
NetScopeMatchesboolReturns whether a pair of objects has the net relationship that the rule's NetScope requires.
PriorityushortReturns the rule's position in the board's priority order for rules of the same RuleKind, starting at 1.
Scope1IncludesboolReturns whether the given object is in the rule's first scope (Scope1Expression).
Scope2IncludesboolReturns whether the given object is in the rule's second scope (Scope2Expression).
ScopeKindIsValidboolReturns whether the given scope kind can be used in the rule's scope.

ActualCheck​

Checks the given object, or pair of objects, against the rule and returns the first violation found.

IPCB_Violation ActualCheck(IPCB_Primitive argP1, IPCB_Primitive argP2);
ParameterTypePassingDescription
argP1IPCB_PrimitivevalueThe object to check, or the first object of the pair.
argP2IPCB_PrimitivevalueThe second object of the pair; null for a rule kind that applies to single objects (IsUnary is true).

Returns: IPCB_Violation

Extension method of IPCB_RuleHelper (using PCB;).

Returns null when no violation is found.

ActualCheck_1​

Checks a pair of objects against the rule and adds every violation found to a list.

bool ActualCheck_1(IPCB_Primitive argP1, IPCB_Primitive argP2, IInterfaceList argViolations);
bool ActualCheck_1(object argP1, object argP2, object argViolations);
ParameterTypePassingDescription
argP1IPCB_PrimitivevalueThe first object of the pair.
argP2IPCB_PrimitivevalueThe second object of the pair.
argViolationsIInterfaceListvalueThe list that receives the violations found (IPCB_Violation objects).

Returns: bool

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

Returns false without checking when one of the arguments is null; otherwise returns true, whether or not violations were found.

CheckBinaryScope​

Returns whether a pair of objects is in the rule's scope, in either order.

bool CheckBinaryScope(IPCB_Primitive argP1, IPCB_Primitive argP2);
bool CheckBinaryScope(object argP1, object argP2);
ParameterTypePassing
argP1IPCB_Primitivevalue
argP2IPCB_Primitivevalue

Returns: bool

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

Returns true when one object is in the first scope (Scope1Includes) and the other in the second scope (Scope2Includes). Returns false when the rule is not enabled for checking (DRCEnabled is false).

CheckUnaryScope​

Returns whether the given object is in the scope of a rule that applies to single objects.

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

Returns: bool

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

Returns true when the rule is enabled for checking (DRCEnabled) and the object matches Scope1Expression. Returns false when the expression cannot be evaluated.

Export_ToParameters_1​

Writes the rule's properties to a parameter string.

void Export_ToParameters_1(ref string argParams);
ParameterTypePassingDescription
argParamsstringrefThe string that receives the parameters.

Returns: nothing (void)

The previous content of the string is replaced. The parameters include Description, which has the form <kind name> [<summary>], built from ShortDescriptorString and DataSummaryString.

GetWhatsThisHelpString​

Returns the help topic identifier of the rule kind, for example PCB_ClearanceRule_ for a clearance rule.

string GetWhatsThisHelpString();

Returns: string

Returns an empty string for a rule kind without a help topic.

IsUnary​

Returns whether the rule kind applies to single objects rather than to pairs of objects.

bool IsUnary();

Returns: bool

NetScopeMatches​

Returns whether a pair of objects has the net relationship that the rule's NetScope requires.

bool NetScopeMatches(IPCB_Primitive argP1, IPCB_Primitive argP2);
bool NetScopeMatches(object argP1, object argP2);
ParameterTypePassing
argP1IPCB_Primitivevalue
argP2IPCB_Primitivevalue

Returns: bool

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

Rule kinds that do not use a net scope return true for any pair.

Priority​

Returns the rule's position in the board's priority order for rules of the same RuleKind, starting at 1.

ushort Priority();

Returns: ushort

Returns 0 when the rule is not on a board.

Scope1Includes​

Returns whether the given object is in the rule's first scope (Scope1Expression).

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

Returns: bool

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

Returns false when the rule is not enabled for checking (DRCEnabled is false). The expression All includes every object.

Scope2Includes​

Returns whether the given object is in the rule's second scope (Scope2Expression).

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

Returns: bool

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

Returns false when the rule is not enabled for checking (DRCEnabled is false). The expression All includes every object.

ScopeKindIsValid​

Returns whether the given scope kind can be used in the rule's scope.

bool ScopeKindIsValid(TScopeKind argScopeKind);
bool ScopeKindIsValid(int argScopeKind);
ParameterTypePassing
argScopeKindTScopeKindvalue

Returns: bool

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

The result depends on the rule kind. For example, a short-circuit rule accepts only board, net and net class scopes, and a confinement rule only footprint, component and component class scopes. Rule kinds that do not restrict the scope kinds return true for every value.

Inherited members​

Returned by​

IPCB_Board.FindDominantRuleForObject, IPCB_Board.FindDominantRuleForObjectPair, IPCB_ServerInterface.PCBRuleFactory

Accepted by​

IPCB_Board.RuleNameUnique, IPCB_ManufactruingRuleList.AddPCBRule