Is it possible to run an FME Workspace from within an ArcGIS 10.x Python Toolbox (.pyt)?
I've got ArcGIS Desktop v10.6.1 installed, with 64-bit Background Geoprocessing installed and switched on. And I've got FME 2019.0.1 (64-bit) installed.
I know how to run a workspace in Python, as explained here, and that works all fine in 64-bit.
But when I try to embed some very simple FME Python code in an ArcGIS Python Toolbox, it crashes my ArcGIS! I guess it's something to do with ArcGIS being 32-bit by default that causes it, so maybe it cannot be done. But I'd still like to find out if anybody else has managed to crack this.
This is what I do:
- In ArcGIS, right-click in a folder and add New > Python Toolbox. This creates a Toolbox.pyt file with a tool called 'Tool' in it.
- Right-click the Toolbox.pyt file, and select Edit, which opens the file in my IDE
- Add the 3 usual lines to import fmeobjects at the top (see below in bold)
- Set "self.canRunInBackground = True", which ensures the tool runs in the background, i.e. in 64-bit (I hope/assume). This setting also unticks the "Always run in foreground" tickbox
- Run the Tool with the toolbox, and... Crash ArcGIS!!
Any ideas or suggestions?
import arcpy
import sys
sys.path.append(r"C:\Program Files\FME2019.0\fmeobjects\python27")
import fmeobjects
class Toolbox(object):
def __init__(self):
"""Define the toolbox (the name of the toolbox is the name of the .pyt file)."""
self.label = "Toolbox"
self.alias = ""
# List of tool classes associated with this toolbox
self.tools = (Tool]
class Tool(object):
def __init__(self):
"""Define the tool (tool name is the name of the class)."""
self.label = "Tool"
self.description = ""
self.canRunInBackground = True
(...)