Question

Run workspace in ArcGIS Python toolbox (.pyt) ?

  • 2 July 2019
  • 1 reply
  • 26 views

Badge +3

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:

  1. 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.
  2. Right-click the Toolbox.pyt file, and select Edit, which opens the file in my IDE
  3. Add the 3 usual lines to import fmeobjects at the top (see below in bold)
  4. 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
  5. 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

(...)

1 reply

Userlevel 2
Badge +17

Hi @arnold_bijlsma

To run a workspace using the FMEWorkspacerRunner class in a Python toolbox without ArcGIS crashing, I had to disable the fme.dll that is installed with ArcGIS. To do so you can follow the instructions in this article (see 2. The Python interpreter may find an incorrect, unlinked, or unlicensed fme.dll subsection b).

Disabling the fme.dll in <ArcGIS Install>\\Desktop10.6\\bin64\\ allowed the FMEWorkspaceRunner.run() method to run successfully (a popup dialog for parameters should appear). However, to run FMEWorkspaceRunner.runWithParameters() successfully, the fme.dll in <ArcGIS Install>\\Desktop10.6\\bin\\ also had to be disabled.

This was tested using ArcGIS Desktop 10.6.1 with 64-bit Background Geoprocessing installed and FME 2019.0.2 (build 19260 win64).

Please note the method described in section 2a of the linked article (extending FME into ArcGIS using the FME Integration Console) may also work but I have not tried this method.

I hope this information helps.

 

Reply