ISch_Iterator interface
An iterator object interface represents an existing iterator object which iterates through a design database to fetch specified objects within a specified region if necessary.
public interface ISch_Iterator
Namespace: SCH · Assembly: Altium.SDK.Interfaces
Remarks
The TIterationDepth type denotes how deep the iterator can look - look for first level objects (for example standalone system parameters of the document only, or all levels for example all parameters on the document including system parameters, objects' parameters such as component's parameters. By default, eIterateAllLevels value is used.
SetState_FilterAll denotes that all objects and the whole schematic document is to be searched within. Otherwise, use the following AddFilter_ObjectSet, AddFilter_Area etc methods to set up a restricted search.
Example
Count the ports on the current schematic sheet.
using SCH;
ISch_Document currentSheet = SCH.GlobalVars.SchServer?.GetCurrentSchDocument();
if (currentSheet == null)
return;
int portNumber = 0;
ISch_Iterator iterator = currentSheet.SchIterator_Create();
if (iterator == null)
return;
iterator.AddFilter_ObjectSet(new SCH.TObjectSet { TObjectId.ePort });
try
{
ISch_BasicContainer port = iterator.FirstSchObject();
while (port != null)
{
portNumber = portNumber + 1;
port = iterator.NextSchObject();
}
}
finally
{
currentSheet.SchIterator_Destroy(ref iterator);
}
Properties
| Property | Type | Access | Description |
|---|---|---|---|
| IterationDepth | TIterationDepth | set | The TIterationDepth type denotes how deep the iterator can look on a document. |
IterationDepth
The TIterationDepth type denotes how deep the iterator can look on a document.
void SetState_IterationDepth(TIterationDepth argIterationDepth);
Type: TIterationDepth · Access: write-only
The accessors are extension methods of ISch_IteratorHelper (using SCH;).
Look for first level objects, for example standalone system parameters of the document only, or all levels for example all parameters on the document including system parameters, objects' parameters such as component's parameters.
By default, eIterateAllLevels value is used.
See also: TIterationDepth
Examples: Ciiva
Methods
| Method | Returns | Description |
|---|---|---|
| AddFilter_Area | void | The AddFilter_Area method defines the rectangular bounds (X1,Y1 and X2,Y2) of the schematic/library document that the iterator will search within. |
| AddFilter_CurrentDisplayModePrimitives | void | This method sets the iterator to look for current display mode primitives only. |
| AddFilter_CurrentPartPrimitives | void | This method sets up the filter of the iterator to look for the current primitives of a part only. |
| AddFilter_ObjectSet | void | This method defines which objects the iterator will look for on a schematid document or a library document. |
| AddFilter_PartPrimitives | void | This method sets up the filter of the iterator to look for primitives of a part (of a component). |
| FirstSchObject | ISch_BasicContainer | The FirstSchObject method fetches the first object found by the iterator. |
| NextSchObject | ISch_BasicContainer | The NextSchObject method fetches the next object found by the iterator. |
| SetState_FilterAll | void | This method sets the iterator to look for everything on a document. |
AddFilter_Area
The AddFilter_Area method defines the rectangular bounds (X1,Y1 and X2,Y2) of the schematic/library document that the iterator will search within.
void AddFilter_Area(int argx1, int argy1, int argx2, int argy2);
| Parameter | Type | Passing |
|---|---|---|
argx1 | int | value |
argy1 | int | value |
argx2 | int | value |
argy2 | int | value |
Returns: nothing (void)
AddFilter_CurrentDisplayModePrimitives
This method sets the iterator to look for current display mode primitives only. A component can be represented by different modes - ie there can be different graphical representations of the same component type.
void AddFilter_CurrentDisplayModePrimitives();
Returns: nothing (void)
AddFilter_CurrentPartPrimitives
This method sets up the filter of the iterator to look for the current primitives of a part only. A component can be composed of multiple parts and each part is identified by its PartID value.
void AddFilter_CurrentPartPrimitives();
Returns: nothing (void)
AddFilter_ObjectSet
This method defines which objects the iterator will look for on a schematid document or a library document.
void AddFilter_ObjectSet(TObjectSet argObjectSet);
void AddFilter_ObjectSet(ITransportSet argObjectSet);
| Parameter | Type | Passing |
|---|---|---|
argObjectSet | TObjectSet | value |
Returns: nothing (void)
The first overload is an extension method of ISch_IteratorHelper (using SCH;) with typed parameters; the second is declared by the interface.
See also: TObjectSet
Examples: Ciiva, Extension_ModifySchWireColor
AddFilter_PartPrimitives
This method sets up the filter of the iterator to look for primitives of a part (of a component). A component can be a multi-part component, for example a 74LS04 can have four parts and they are identified by the PartID value.
void AddFilter_PartPrimitives(int argPartId, byte argDisplayMode);
| Parameter | Type | Passing |
|---|---|---|
argPartId | int | value |
argDisplayMode | byte | value |
Returns: nothing (void)
FirstSchObject
The FirstSchObject method fetches the first object found by the iterator. The FirstSchObject method is to be invoked first and then in a While null loop, the NextSchObject is called repeatedly until it returns a nil value where the loop is terminated.
ISch_BasicContainer FirstSchObject();
Returns: ISch_BasicContainer
Extension method of ISch_IteratorHelper (using SCH;).
See also: ISch_Iterator.NextSchObject
Examples: Ciiva, Extension_ModifySchWireColor
NextSchObject
The NextSchObject method fetches the next object found by the iterator. The FirstSchObject method is to be invoked first and then in a While null loop, the NextSchObject is called repeatedly until it returns a nil value where the loop is terminated.
ISch_BasicContainer NextSchObject();
Returns: ISch_BasicContainer
Extension method of ISch_IteratorHelper (using SCH;).
See also: ISch_Iterator.FirstSchObject
Examples: Ciiva, Extension_ModifySchWireColor
SetState_FilterAll
This method sets the iterator to look for everything on a document.
void SetState_FilterAll();
Returns: nothing (void)
Returned by
ISch_BasicContainer.SchIterator_Create, ISch_Lib.SchLibIterator_Create
Accepted by
ISch_BasicContainer.SchIterator_Destroy
Examples
Used in the SDK examples: Ciiva, Extension_ModifySchWireColor.