span8
span4
span8
span4
To run an FME Workspace using python outside of FME Workbench you can edit the attached sample and include it within your python script.For example an ArcGIS geoprocessing script written in python could launch an FME Workspace to preprocess some data or translate some data output.
import syssys.path.append("C:\\apps\\FME2014\\fmeobjects\\python27")
The script below will run your workspace with the specified parameters and return either a success message or an FME Exception.Download the attached version of the script to better preserver indentations etc.Edit the path to the workspace where you see theworkspacevariable and the published parameters names and values where you see theparametersdictionary being created to reflect your own environment.
The script uses theFMEWorkspaceRunnerclass and therunWithParameters()method found within fmeobjects.You can also use thepromptRun()method to prompt for published parameters by uncommenting the appropriate line below.
import fmeobjects# initiate FMEWorkspaceRunner Class runner = fmeobjects.FMEWorkspaceRunner() # Full path to Workspace,example comes from the FME 2014 Training Full Datasetworkspace = 'C:\FMEData2014\Workspaces\DesktopBasic\Exercise1a-Complete.fmw'# Set workspace parameters by creating a dictionary of name value pairsparameters = {}parameters['SourceDataset_MITAB'] ='C:\FMEData2014\Data\Zoning\Zones.tab'parameters['DestDataset_ACAD'] = 'C:\FMEData2014\Output\Training\Zones.dwg' # Use Try so we can get FME Exceptiontry: # Run Workspace with parameters set in above directory runner.runWithParameters(workspace,parameters) # or use promptRun to prompt for published parameters #runner.promptRun(workspace)except fmeobjects.FMEException as ex: # Print out FME Exception if workspace failed print ex.messageelse: #Tell user the workspace ran print('The Workspace %s ran successfully'.format(workspace))# get rid of FMEWorkspace runner so we don't leave an FME process runningrunner = None
Ex: parameters['Sourcedataset_FILEGDB'] = r'\\location\storage.gdb\%s_featureclass' % wildcard
parameters['SourceDataset_ACAD'] = r"""C:\Input\01.dwg" "C:\Input\02.dwg" "C:\Input\03.dwg"""Individual files need to be enclosed in double quotes and separated with a space.The overall parameter string needs to be enclosed with two double quotes in order to run successfully.
Pass a List of Tables or Layers to an FME Reader using Python Scripted Parameters
Example 亚搏在线Workflow using FME,Python and Oracle
Errors FMEWorkspaceRunner Python | Errors FMEObjects Python
Create Spatial Index after loading to ArcSDE - using Load only mode
Setting up a workspace to deploy in production,staging and local
Extracting a schema subset for dynamic schemas
Using a Python Startup/Shutdown Script or PythonCaller to Perform Geoprocessing with Arcpy
Transfer Workspace File Output Using SFTP (FME Server 2015 and below)
© 2019 亚搏在线Safe Software Inc |Legal