span8
斯潘4
要在FME工作台之外使用python运行一个FME工作区,您可以编辑附加的示例并将其包含在您的python脚本中。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.编辑您看到的工作区路径workspacevariable and the published parameters names and values where you see the参数正在创建反映您自己环境的字典。
脚本使用fmeWorkspaceRunner(工作空间管理器)类与runWithParameters()在fmeobjects中找到的方法。您也可以使用promptRun()方法通过取消对下面相应行的注释来提示输入已发布的参数。
导入fmeObjects启动fmeWorkspaceRunner类runner=fmeObjects.fmeWorkspaceRunner()工作区的完整路径,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,参数)或使用promptron提示输入已发布的参数runner.promptron(工作区),除了fmeobjects.fme exception as ex:如果工作区打印失败,则打印出fme exception ex.messageelse:告诉用户工作区已运行打印(“工作区%s已成功运行”。格式化(工作区))删除fme workspace runner,以便不't让FME过程运行=无
例如:参数['sourcedataset_filegdb']=r'\location\storage.gdb\%s_featureclass'%通配符
parameters['SourceDataset_ACAD'] = r"""C:\Input\01.dwg" "C:\Input\02.dwg" "C:\Input\03.dwg"""单独的文件需要用双引号括起来,并用空格隔开。为了成功运行,整个参数字符串需要用两个双引号括起来。
?2019安全亚搏在线软件公司|Legal