Question

FME GUI Directives with Python Scripted Parameters


Badge +1
  • Participant
  • 126 replies
I have put a GUI Directives script in my Python start up script that prompts the user to choose a feature. I store the choice in the fme.macroValues dictionary.

 

 

Next I want to take that choice and pass it to Python scripted parameters to retrieve settings from a json file. This works when I use the FME built in parameters, but when I use the GUI Directives method I get the error that the Python scripted parameter does not have the fme.macroValues value. Looks like the Python scripted parameters fire BEFORE the GUI Directives, even though the latter is in the startup script. Is there any way to force the start up script to fire before the Python scripted parameters?

 

 

Thanks

2 replies

Userlevel 2
Badge +17
Hi,

 

 

As you mentioned, values of all user parameters including scripted ones are determined before performing the start up script. The order of processes - configure user parameters at first and then perform startup script  - cannot be modified, so I don't think there is a way to use a value defined with the startup script in a scripted parameter.

 

 

A workaround I can think of is:

 

- assign the value to a Python global variable in the startup script;

 

- use the global variable value with a script written in a PythonCaller/PythonCreator.

 

 

And, although I've never tested, it might be possible to perform the prompting script itself in a scripted parameter. But I would not recommend this way even if it was possible technically, since it's relatively hard to debug a complicated script written in a scripted parameter.

 

 

Takashi
Badge +1
Yes, I could take out the scripted parameters and have one Python caller that sets the values after the prompting script. However, for our Python-challenged team it is daunting to go into a Python caller and figure out what is happening. A scripted parameter is also Python, but the code in each is simple and repeatable, such that even a non Python staff member can work with it.

 

 

Thanks for the confirmation about the order of execution in FME. I would have thought that "start up script" means that this script executes before any "real" FME, but that is not the case.

Reply