#============================================================================ # # Name : RunWorkspace.py # # Purpose : FMEPedia Sample of FMEWorkspaceRunner # # Author Date Changes made # ------------------ ------------ ------------------------------- # Ken Bragg July 15th, 2014 Original Definition # Note: # The path to fmeobjects must by in your python path so you may need something like this: # import sys # sys.path.append("C:\\apps\\FME2014\\fmeobjects\\python27") import fmeobjects #initiate FMEWorkspaceRunner Class runner = fmeobjects.FMEWorkspaceRunner() #Full path to Workspace, example comes from the FME 2014 Training Full Dataset workspace = 'C:\FMEData2014\Workspaces\DesktopBasic\Exercise1a-Complete.fmw' #Set workspace parameters by creating a dictionary of name value pairs parameters = {} 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 Exception try: # Run Workspace with parameters set in above dictionary runner.runWithParameters(workspace, parameters) #Or use promtRun to prompt for published parameters #runner.promptRun(workspace) except fmeobjects.FMEException as ex: #Print out FME Exception if worskspace failed print ex.message else: #Tell user the workspace ran print('The Workspace: ' + workspace) print('...ran successfully') #get rid of FMEWorkspace runner so we don't leave an FME process running runner = None