Skip to main content

Problem:

I want to use the arcmap dissolver because the FME dissolver makes some problems.

I tried the following:

Workbench:

PythonCaller Parameters:

Python Script inside PythonCaller:

I got the following Error-Message:


Python Exception <NameError>: global name
'test_output' is not defined

Error encountered while calling function
`DissolveWithArcpy'

f_10(PythonFactory):
PythonFactory failed to process Feature

I don't know where and how to tell FME what the output is.

Hi iwem,

 

Just a stupid idea but what happens when you add test_output = None right before you call the arcpy dissolve function?

Unfortunately, this isn't going to work. The FME "feature" object isn't compatible with the feature class reference that Dissolve_management() expects.

In short, you'll have to write all your FME features to a separate feature class and then run Dissolve_management() on that feature class after all the features have been written. The easiest may be to use a FeatureWriter followed by a PythonCaller.

Jeroen is right about test_output being undefined, but that isn't the main problem.


Hi there!  To use Python and ArcPy within FME you should use the fmeobject Library :

import fmeobjects
import arcpy

It allow you to use attribute and any value on the feature you are using.

feature.getAttribute('your attribute name here')

feature.setAttribute("New attribute name here", value from python here)

Once you get the wright syntax in python code, FME will execute the code perfectly...

I use a lot of python, arcpy and FME together and It's very usefull!


Thanks a lot for your answers!

I tried to insert a FeatureWriter.

Now my workbench looks like:

In the feature writer I took the input-data and wrote all the Features to a local ESRI File Geodatabase.

Then I changed my python script to:

Now I get the following Error Message:

Python Exception <RuntimeError>: Object: Error in executing tool

 

Error encountered while calling function `DissolveWithArcpy'

 

f_8(PythonFactory): PythonFactory failed to process feature

 

Abnormal termination of the Geodatabase reader

 

Closing the Geodatabase Reader

What's wrong?


As mentioned, you cannot pass the "feature" object to Dissolve_management, it expects a string with the fully qualified name of the feature class

Try something like:

 

test_output = 'c:/temp/temp.gdb/test_output'
test_input = 'c:/temp/temp.gdb/test_input_iwem'
arcpy.Dissolve_management(test_input, test_output, 'Gemeindename', '', 'SINGLEPART')

As you can see, the first parameter to Dissolve_management is a string, not an instance of fmeobjects.FMEFeature.

You should probably also delete the last line of your python script, "pyoutput(test_output)"


Thanks a lot for your answers!

I tried to insert a FeatureWriter.

Now my workbench looks like:

0684Q00000ArLs9QAF.png

In the feature writer I took the input-data and wrote all the Features to a local ESRI File Geodatabase. 

0684Q00000ArLtwQAF.png

Then I changed my python script to:

0684Q00000ArLpUQAV.png

Now I get the following Error Message:

Python Exception <RuntimeError>: Object: Error in executing tool

 

Error encountered while calling function `DissolveWithArcpy'

 

f_8(PythonFactory): PythonFactory failed to process feature

 

Abnormal termination of the Geodatabase reader

 

Closing the Geodatabase Reader

What's wrong?

As mentioned, you cannot pass the "feature" object to Dissolve_management, it expects a string with the name of the feature class.

 

Try something like:

 

test_output = 'c:/temp/temp.gdb/test_output'
test_input = 'c:/temp/temp.gdb/test_input_iwem'
arcpy.Dissolve_management(test_input, test_output, 'Gemeindename', '', 'SINGLEPART')
As you can see, the first parameter to Dissolve_management is a string, not an instance of fmeobjects.FMEFeature.

Thanks a lot for your anwer david_r!

Now it works! :)


Reply