For Each

From Visual3D Wiki Documentation
Jump to: navigation, search
Language:  English  • français • italiano • português • español 

Executes pipeline commands multiple times for each item in a list of items. It is not identical with a "for loop" or "do loop" in a programming language because the items must be explicitly defined as ITEMS in the command. This has some powerful consequences because it means that you can "loop" through disconnected items or strings as easily as using a structured list.

Command Syntax

/Iteration_Parameter_Name= INDEX
! Starting from the For_Each command and ending at the End_For_Each command
! the loop is repeated once for each item in the For_Each command at each
! loop INDEX is a pipeline command this is identified as ::INDEX in any other command

As of version 5.02.17, a new parameter "ITERATION_PARAMETER_COUNT_NAME" count was added. A pipeline parameter name (ex. INDEX_COUNT) can be placed here. Any where the parameter INDEX_COUNT is referenced, will return the iteration number (the result will be 1 based, so the first loop through will return 1, and the second will return 2).

Example: Compute the GLOBAL mean value of a signal for each of 3 tags

This example computes the GLOBAL mean value of a signal for each of 3 tags (TAG1, TAG2, TAG3) and adds the TAG name to the GLOBAL signal names that are created.

/Iteration_Parameter_Name= TAG_NAMES
/Items= TAG1+TAG2+TAG3

/File_Name= ::TAG_NAMES



Example: Implementing a while loop

Visual3D doesn't have a WHILE command, so there is no option but to use a kludge. You will need to set the option to make Visual3D stop processing the pipeline on the first error. The Visual 3D solution for the following algorithm can be found on Example: Implementing a while loop.

Variable blnContinue = true
While Continue = true
Prompt user for variable blnContinue (true or false)
FileCounter = FileCounter +1
[load and process another file (e.g. filename_filecounter)]
End while

Example: Processing many files

First create a pipeline parameter that contains all of the filenames selected (e.g. all files that have the same TAG) concatenated into a string.


! Now set up the for each loop using this string


! Put any command that you like into this location


! NOTE: Filenames do not have to be in any sequence or have any special naming convention.

Exporting multiple files

Using Export_Data_to_ASCII_File to export data from individual C3D files to unique text files.



Retrieved from ""