Skip to main content

How does one pass a user parameter to a pythonCaller that's inside a customTransformer

import fme
import fmeobjects
 
def processFeature(feature):
    p = FME_MacroValuesÂ'SomeUserParameter']
    print p 

I read here "If you put your pythonCaller inside a custom transformer, the parameter name changes to {customTransformerName}_SomeUserParameter. "

I tried then doing this below but still does not work.

import fme 
import fmeobjects  
def processFeature(feature):
     p = FME_MacroValuesr'{customTransformerName}_SomeUserParameter']     
     print p 

What am I doing wrong?

 

Try to put a ParameterFetcher in the Main part of the workspace and fetch your user parameter. Then go into the custom transformer, open the settings for the Input and expose your parameter.


It's not the custom transformer name, it's the custom transformer instance name, so if you have two instances of the custom transformer, the MacroValues are going to be different.

 

 

It's much better to use a parameterFetcher inside the custom transformer to store your parameter as an attribute, and then reference it by feature.getAttribute('_ParamAttr'). This will be consistent no matter how many times the custom transformer is used, or renamed.

It's not the custom transformer name, it's the custom transformer instance name, so if you have two instances of the custom transformer, the MacroValues are going to be different.

 

 

It's much better to use a parameterFetcher inside the custom transformer to store your parameter as an attribute, and then reference it by feature.getAttribute('_ParamAttr'). This will be consistent no matter how many times the custom transformer is used, or renamed.

This is the sensible approach. The parameter naming inside custom transformers is horrible. Fortunately one can easily clean up all the internal attributes when outputting features from the transformer.


This is the sensible approach. The parameter naming inside custom transformers is horrible. Fortunately one can easily clean up all the internal attributes when outputting features from the transformer.

All my temporary attributes inside a custom transformer begin with ! so they are exceedingly unlikely to conflict with existing data, no matter who is using the custom transformer.

Even better is to use a specific prefix for each custom transformer. ex !GAC_ for GeographicalAreaCalculator.


Reply