span8
span4
span8
span4
I am using PythonCaller and have wrote a script for it.I have tested my script outside of FME and it works.
Script creates a column and calculates value for it.When I run my fme,I am getting this error:
PythonFactory failed to load python symbol `processFeature(feature)'
Factory proxy not initialized
f_24(PythonFactory): PythonFactory failed to process feature
The PythonCaller Parameters:
Script:
import fme,fmeobjects
import arcpyfrom collections import Counterdef processFeature(feature): # The location of the destination geodatabase and feature class feat_class = feature # Add new field for new value arcpy.AddField_management(feat_class,"countVehicle","SHORT") # add all values for brigade unique id to a list all_values = list() with arcpy.da.SearchCursor(feat_class,["T_LOCATION_CODE"]) as cursor: for row in cursor: all_values.append(row[0]) # Calculate field fields = ["T_LOCATION_CODE","countVehicle"] with arcpy.da.UpdateCursor(feat_class,fields) as cursor2: for row2 in cursor2: if row2[0] in Counter(all_values): row2[1] = Counter(all_values)[row2[0]] cursor2.updateRow(row2)
Also be aware that this probably won't work as you expect:
feat_class = feature
"feature" will refer to an instance offmeobjects.FMEFeature,not a string,and arcpy won't know what to do about it.
If the input feature contains the feature class name as an attribute,you can do something like:
feat_class = feature.getAttribute('my_attribute_containing_feature_class_name')
In the class or function to process feature box you just want processFeature not processFeature(feature)
Python and list with null value2 Answers
How to select a particular layer in FME - Python scripting?1 Answer
Where do I install python 3.6 packages to FME 2018?2 Answers
Cellwise raster manipulation by indexing row/col using the Python API2 Answers
Use PythonCaller to get list of files in directory on FTP site6 Answers
© 2019 亚搏在线Safe Software Inc |Legal