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
| Property | Type | Access | Description |
|---|---|---|---|
| CollisionExpansion | int | get | The rule's collision expansion distance, in internal units (10,000 per mil). |
| Comment | string | get; set | A free-text comment on the rule. |
| DataSummaryString | string | get | A short text that lists the rule's constraint values. |
| DefinedByLogicalDocument | bool | get; set | Whether the rule comes from the rule definitions of the design's logical (schematic) documents. |
| DRCEnabled | bool | get; set | Whether the rule is checked by design rule checking. |
| LayerKind | TRuleLayerKind | get; set | Whether the rule tests objects on the same layer or on adjacent layers. |
| Name | string | get; set | The name of the rule. |
| NetScope | TNetScope | get; set | Which net relationship a pair of objects must have for the rule to apply to them. |
| RuleKind | TRuleKind | get; set | The kind of design rule, for example TRuleKind.eRule_Clearance. |
| Scope1Expression | string | get; set | The query expression that selects the objects of the rule's first scope, for example All. |
| Scope2Expression | string | get; set | The query expression that selects the objects of the rule's second scope, for rule kinds that apply to pairs of objects. |
| ScopeDescriptorString | string | get | A text that shows the rule's scope expressions. |
| ShortDescriptorString | string | get | The display name of the rule kind, for example Clearance Constraint for a clearance rule. |
| ViolationDescriptorString | string | get | A 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
| Method | Returns | Description |
|---|---|---|
| ActualCheck | IPCB_Violation | Checks the given object, or pair of objects, against the rule and returns the first violation found. |
| ActualCheck_1 | bool | Checks a pair of objects against the rule and adds every violation found to a list. |
| CheckBinaryScope | bool | Returns whether a pair of objects is in the rule's scope, in either order. |
| CheckUnaryScope | bool | Returns whether the given object is in the scope of a rule that applies to single objects. |
| Export_ToParameters_1 | void | Writes the rule's properties to a parameter string. |
| GetWhatsThisHelpString | string | Returns the help topic identifier of the rule kind, for example PCB_ClearanceRule_ for a clearance rule. |
| IsUnary | bool | Returns whether the rule kind applies to single objects rather than to pairs of objects. |
| NetScopeMatches | bool | Returns whether a pair of objects has the net relationship that the rule's NetScope requires. |
| Priority | ushort | Returns the rule's position in the board's priority order for rules of the same RuleKind, starting at 1. |
| Scope1Includes | bool | Returns whether the given object is in the rule's first scope (Scope1Expression). |
| Scope2Includes | bool | Returns whether the given object is in the rule's second scope (Scope2Expression). |
| ScopeKindIsValid | bool | Returns 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);
| Parameter | Type | Passing | Description |
|---|---|---|---|
argP1 | IPCB_Primitive | value | The object to check, or the first object of the pair. |
argP2 | IPCB_Primitive | value | The 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);
| Parameter | Type | Passing | Description |
|---|---|---|---|
argP1 | IPCB_Primitive | value | The first object of the pair. |
argP2 | IPCB_Primitive | value | The second object of the pair. |
argViolations | IInterfaceList | value | The 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);
| Parameter | Type | Passing |
|---|---|---|
argP1 | IPCB_Primitive | value |
argP2 | IPCB_Primitive | value |
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);
| Parameter | Type | Passing |
|---|---|---|
argP | IPCB_Primitive | value |
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);
| Parameter | Type | Passing | Description |
|---|---|---|---|
argParams | string | ref | The 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);
| Parameter | Type | Passing |
|---|---|---|
argP1 | IPCB_Primitive | value |
argP2 | IPCB_Primitive | value |
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);
| Parameter | Type | Passing |
|---|---|---|
argP | IPCB_Primitive | value |
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);
| Parameter | Type | Passing |
|---|---|---|
argP | IPCB_Primitive | value |
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);
| Parameter | Type | Passing |
|---|---|---|
argScopeKind | TScopeKind | value |
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
- From IPCB_Primitive: AllowGlobalEdit, BeginModify, Board, BoundingRectangle, BoundingRectangleChildren, BoundingRectangleForPainting, BoundingRectangleForSelection, CancelModify, Component, Coordinate, DescriptorString, DetailString, Dimension, DrawAsPreview, DRCError, Enabled, Enabled_Direct, Enabled_vComponent, Enabled_vCoordinate, Enabled_vDimension, Enabled_vNet, Enabled_vPolygon, EnableDraw, EndModify, Export_ToParameters, FlipXY, GraphicallyInvalidate, Handle, Identifier, InBoard, InComponent, InCoordinate, Index, InDimension, InNet, InPolygon, InSelectionMemory, IsAssyTestPoint_Bottom, IsAssyTestPoint_Top, IsElectricalPrim, IsFreePrimitive, IsHidden, IsKeepout, IsPreRoute, IsSaveable, IsTenting, IsTenting_Bottom, IsTenting_Top, IsTestPoint_Bottom, IsTestPoint_Top, Layer, MiscFlag1, MiscFlag2, MiscFlag3, Moveable, MoveByXY, MoveToXY, Net, ObjectID, ObjectIDString, PadCacheRobotFlag, PasteMaskExpansion, Polygon, PolygonOutline, PowerPlaneClearance, PowerPlaneConnectStyle, PowerPlaneReliefExpansion, Preview, ReliefAirGap, ReliefConductorWidth, ReliefEntries, Replicate, RequiredParamterSpace, RotateBy, Selected, SolderMaskExpansion, SwapLayerPairs, TearDrop, UnionIndex, UniqueId, UniqueID, Used, UserRouted, V7Layer, ViewableObjectID
Returned by
IPCB_Board.FindDominantRuleForObject, IPCB_Board.FindDominantRuleForObjectPair, IPCB_ServerInterface.PCBRuleFactory
Accepted by
IPCB_Board.RuleNameUnique, IPCB_ManufactruingRuleList.AddPCBRule