Skip to main content

Hy there !

I’m using FME 2022.2 and ArcGISpro 3.1.1, Python Compatibility is set to Esri ArcGIS Python 3.6+

I want to test arcpy in FME with the following script, it works but throws this error:

Python Exception <TypeError>: clip_shapefile() missing 2 required positional arguments: 'clip_features' and 'output_shapefile'
 

Clip works well and the shapefile is valid, but the pythoncaller ends up with this error.

The Script:

import fme
import fmeobjects
import arcpy
import os

# Overwrite
arcpy.env.overwriteOutput = True

# Function
def clip_shapefile(input_shapefile, clip_features, output_shapefile):
    arcpy.Clip_analysis(input_shapefile, clip_features, output_shapefile)
    return output_shapefile

# Source
input_shapefile = 'D:/TEMP/SHP/VWG_KAT_GEM.shp'
print("Quelle gelesen !")

#Clip Features
clip_features = 'D:/TEMP/SHP/VWG_POLGEM_OBERGRAFENDORF.shp'
print("Clip Features gelesen !")

# Dest
output_shapefile = 'D:/TEMP/_TEMP/VWG_POLGEM_OBERGRAFENDORF.shp'
print("Ausgabepfad festgelegt !")

# Function
clip_shapefile(input_shapefile, clip_features, output_shapefile)
print("Clippen läuft ...")

# PythonCaller-Output
fmeobjects.FMELogFile().logMessageString("Ergebnis: " + output_shapefile)

 

Regards

al
 

 

 

Hi, @geoal.

From taking a look at your script and the following error, I have a clarifying question to ask.

Have you set the arcpy.env.workspace variable to the file path your using? It may need to be referenced in the script.

Other than that it seems to me that the script looks correct.

Let me know!

Best,


Do i net to set this when i  use the full path inside the script ?

Anyway...i set the variable but it doesn’t change anything :/

 

regards ;)


Hi, @geoal.

It should not be needed, apologies for that.

In terms of the arcpy function that you call in your function, there is an updated one (might be the same functionality as the arcpy function you call) on esri’s site for ArcGIS Pro. They seemed to change the name of it. Its possible its not needed as it mimics the one your using, just a different name.

There is a similar, in context, community question that a user asked about the arcpy clip function but with a custom transformer. The answer I linked is a little outdated so some of those issues may of been resolved in newer versions of FME Form.

If your still stuck, let me know, I can get one of my colleagues to jump on this question thread.

 


Reply