操作方法
通常会使用 ModelBuilder 来自动化耗时的流程。 该模型可能需要在下班后作为计划任务运行,为此需要一个 Python 脚本:
import arcpy arcpy.ImportToolbox(r"path\to\toolbox.tbx") arcpy.ModelName_ToolboxAlias()通常,此操作执行不会出错。 但代码可能抛出 AttributeError 异常,例如:
'module' object has no attribute 'ModelName_ToolboxAlias'或
Object: Tool or environment <> not found.
由于以下原因之一,通过 Python 调用模型可能会引发 AttributeError:
import arcpy arcpy.ImportToolbox(r"path\to\toolbox.tbx") arcpy.ToolboxAlias.ModelName()该错误略有不同,这有助于精确定位 Python 无法找到的对象。
Note: Models that are newly created, as well as any models that have been edited and saved in ModelBuilder in ArcGIS Pro, cannot be used in other ArcGIS for Desktop applications. Therefore, attempts to call a model created in ArcGIS Pro with the ArcPy in Python 2.7, will raise an AttributeError. See: ModelBuilder: Migration to ArcGIS Pro
文章 ID: 000014511
获取来自 ArcGIS 专家的帮助
下载 Esri 支持应用程序