<< Click to Display Table of Contents >> Navigation: Macros > Macro commands and parameters > Macro loop commands > Macro command ForSelection ... End |
Purpose:
Execute a number of macro commands for all objects of a specified type within a selection. The objects are one by one temporary stored into a variable.
The ForSelection-command always occurs together with an End. Between ForSelection and End are the repeatedly executable commands. General notation:
ForSelection ( ExtendedObject( SelectionName ) , ObjectVariableName )
End
An ExtendedObject can be:
•an object (Node, Link, Cable, Line, …), as defined in paragraph 4.1
•Branch: general indication of a branch between two nodes (Link, Cable, …)
•Element: general indication of an element on a node (Source, SynGen, …)
•Object: general indication of a component in the network.
Examples:
Perform an N-1 contingency analyse for all branches in the selection with name 'MV-network':
Set( sheet, 1 );
Set( column, 1 );
Set( row , 1 );
ForSelection( Branch( 'MV-Network' ), failingbranch )
Write( sheet, row , column, failingbranch )
Set( failingbranch.FirstSwitch, open )
Loadflow( 0, , true )
Write( sheet, row, 2, Node('MyNode').upu)
Set( failingbranch.FirstSwitch, closed )
Add( row , 1 )
End
Report for all components in the selection with name 'MySelection' the name:
Set( sheet, 1 )
Set( column, 1 )
Set( row , 0 )
ForSelection( Object( 'MySelection' ), Component )
Add( row , 1 )
Write( sheet, row , column, Component.Name )
End