Skip to main content

I successfully set up a Scripted (Python) Published Parameter called GIS_FILESHARE_ROOT. 

CaptureThe script has the following code:

import sys
sys.path.insert(0, FME_MacroValues,'FME_MF_DIR'])
import config
return config.GIS_FILESHARE_ROOT

This imports config. Config is located in a subdirectory called 'config' of where the fmw lives. This subdirectory has an __init__.py file with the following code:

import os
GIS_FILESHARE_ROOT = os.path.abspath(r'\\server\dir\to\the\filestore\root')

A shapefile reader was added pointing to $(GIS_FILESHARE_ROOT)\sub\shp_folder\TheShapeFile.shp and this successfully reads the shapefile.

 

But, when I try do a similar thing but with a shapefile writer, I get an error.

Undefined macro 'GIS_FILESHARE_ROOT' dereferenced in file ... 

CaptureCan someone help me understand what's happening and how can I setup a similar dynamic root config like I did with the reader?

I got it working. For some reason, if I try to create the writer (or reader) initially setting the $(GIS_FILESHARE_FOOT) parameter, it falls over. I got around it by initially hardcoding the filepath just to create the reader/writer, and then edited the directory path with the $(GIS_FILESHARE_FOOT) parameter.


This is often the way these things need to be set in FME

  1. Create using full filepath, then after creation
  2. Amend filepath parameter to include user parameters or attributes.

Reply