7

In a PythonCaller (FME 2014 SP4 in Data Interop in ArcGIS 10.3), I'd like to do some conditional processing based on the layer that I'm currently processing. I'm feeding in a text file of layers dynamically at runtime, so the layer(s) being processed can vary. I'd like to do something like the psuedocode below:

import fmeobjects
def processFeature(feature):
    # Get which layer is currently being processed
    layer_name = somehow get current layername via fmeobjects??
    # do some logical processing of fields based on what layer we are processing
    pass

Not sure if there is something in FME_MacroValues that exposes this (looked and couldn't find much) or if I need to expose it somehow from my source and then pipe it into my PythonCaller perhaps.

2
  1. Add an AttributeExposer, expose the fme_feature_type attribute
  2. Connect the AttributeExposer to a AttributeCreator to push fme_feature_type out an attribute (named fme_feature_type below)
  3. In the PythonCaller, get your attribute by: layer_name = feature.getAttribute("fme_feature_type")
1

I'm going to assume your text file is like a CSV with a header called "LayerName" and each row is a different layer. In that case, your function would be something like this:

import fmeobjects
def processFeature(feature):
    # Get which layer is currently being processed
    layer_name = feature.getAttribute("LayerName")
    # do some logical processing of fields based on what layer we are processing
    pass
  • Didn't actually try this, but totally seems like a viable solution that should work. Thanks. – Chad Cooper May 23 '16 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.