I am trying to create an attribute index in a feature class in FME 2011. I couldn't find any transformer that does it. I'm thinking that maybe I can use "PythonCaller" transformer to call "Add Attribute Index" geoprocessing method from ArcMap.
Is it possible?
Here's the syntax I copied from ArcMap Help menu:
arcpy.AddIndex_management ("counties.shp", "NAME;STATE_FIPS;CNTY_FIPS", "#", "NON_UNIQUE", "NON_ASCENDING")
I intalled FME2012 on my machine and used python26.dll as my custon Python interpreter and copied @Mark's code. For Entry point, I entered the name of the class "MyIndexingScript". I'm getting the following error:
Python Exception : Object: Error in executing tool Error encountered while calling method `input' PythonFactory failed to process feature
import fmeobjects
import arcpy
class MyIndexingScript(object):
def __init__(self):
self.featureList = []
def input(self,feature):
self.featureList.append(feature)
arcpy.AddIndex_management (self, "YORK_PARCEL_ID;PARCEL_GIS_ID", "PIndex", "UNIQUE", "ASCENDING")
def close(self):
self.pyoutput(feature)
self
directly, as you are, in thearcpy.AddIndex_management
call. Instead you will want to either hard-code the feature class path or read in an attribute or parameter to use there. So something likefc = self.getAttribute('FC_PATH')
and then referencefc
instead ofself
in the AddIndex call. See the PythonCaller help for more details.