Skip to main content
Question

I have a Python 2.7 script that takes command line arguments. I am trying to implement it in a PythonCaller but it doesn't seem to recognize "feature.getAttribute". I'm getting this error "Python Exception <NameError>: name 'feature' is not def

  • November 17, 2022
  • 3 replies
  • 14 views

dolson1157
Contributor
Forum|alt.badge.img

Using an old version - 2019.1.3.1 with ArcGIS 2.7 compatability.

 

In my script I have where:

 

import fme

import fmeobjects

 

 if __name__ == "__main__":

   # Script parameters

   inputLayer = feature.get.Attribute('inputLayer')

   outputLocation = feature.getAttribute('outputLocation')

   outputName = feature.getAttribute('outputName')

3 replies

dolson1157
Contributor
Forum|alt.badge.img
  • Author
  • Contributor
  • November 17, 2022

Sorry - the line

inputLayer = feature.get.Attribute('inputLayer')

 

is acually

inputLayer = feature.getAttribute('inputLayer')


david_r
Celebrity
  • November 17, 2022

You'll have to either use the expected method or the class interface, see https://community.safe.com/s/article/pythoncaller-transformer

 

Basically, your code should look something like:

import fme
import fmeobjects
 
def my_feature_processor(feature):
   # Script parameters
   inputLayer = feature.getAttribute('inputLayer')
   outputLocation = feature.getAttribute('outputLocation')
   outputName = feature.getAttribute('outputName')

You then have to tell the PythonCaller that your entry point is "my_feature_processor"


dolson1157
Contributor
Forum|alt.badge.img
  • Author
  • Contributor
  • November 17, 2022

Thanks david_r,

That worked for me.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings