Looping Custom Transformers
Looping a custom transformer is useful for users who want to leverage existing transformers (Testers, Filters, etc) to determine end conditions.
For example, instead of rerunning a workspace many times and resetting transformer properties, you can set a transformer to "loop" until the conditions are met. This means that any features that enter the transformer will be sent back to its given input if the conditions don't yet match.
These transformers also work well if you want create values for the
fme_color
(or fme_fill_color
) attribute, which would spread color evenly
from dark to light independently on the number of input features.
Note: To set up looping with group-based (or blocking) transformers, see Looping with a Blocking Transformer.
Steps
- Create a Custom Transformer in an existing workspace. You might want to include "Loop" in the name. Include the transformers that will make up the conditions of the loop.
- Right-click in the workspace and choose Insert Transformer Loop, or select the menu Insert > Transformer Loop.
- Choose the Input to loop to (if there's more than one). An output appears on the canvas similar to the following:
- Place the transformer in the main workspace and run the workspace. When the looping transformer reaches the preset parameters in the custom transformer properties, the translation will complete.
Usage Notes
- Looping transformer inputs are based on transformers specific to the workspace you are in.
- Use a Visualizer to check your results.
- Publish parameters if you want to change the output slightly each time you run the workspace. Make sure you press Ctrl+R to run the translation so that you will be prompted for the parameters.
Disabling Published Input
When you want to set a number of iterations as a transformer's parameter, you might want to connect the Loop to another input port. In this case, this input port should not receive any external input features. To do this, click the properties button of the input port to open the Edit Transformer Input dialog. Beside the custom transformer name, unclick the Publish checkbox.
Unpublished input ports can be recognized by a small "lock" icon: