Here is some VBA code to show how you would call a model in a toolbox ' Create workspacefactory Dim pToolboxWorkspaceFactory As IWorkspaceFactory Set pToolboxWorkspaceFactory = New esriGeoprocessing.ToolboxWorkspaceFactory 'Open a toolbox workspace - you need to change the path Dim pToolboxWorkspace As IToolboxWorkspace Set pToolboxWorkspace = pToolboxWorkspaceFactory.OpenFromFile("c:\temp", 0) ' Connect to tool - you need to change the toolbox name and model name Dim pGPToolBox As IGPToolbox Set pGPToolBox = pToolboxWorkspace.OpenToolbox("myToolbox.tbx") Dim pGPTool As IGPTool Set pGPTool = pGPToolBox.OpenTool("mdExplodeToSingleRoutes") ' Run tool Dim pGPToolCommandHelper As IGPToolCommandHelper Set pGPToolCommandHelper = New GPToolCommandHelper pGPToolCommandHelper.SetTool pGPTool pGPToolCommandHelper.Invoke Nothing ' Destroy objects Set pToolboxWorkspaceFactory = Nothing Set pToolboxWorkspace = Nothing Set pGPToolBox = Nothing Set pGPTool = Nothing Set pGPToolCommandHelper = Nothing
' Create workspacefactory Dim pToolboxWorkspaceFactory As IWorkspaceFactory Set pToolboxWorkspaceFactory = New esriGeoprocessing.ToolboxWorkspaceFactory 'Open a toolbox workspace - you need to change the path Dim pToolboxWorkspace As IToolboxWorkspace Set pToolboxWorkspace = pToolboxWorkspaceFactory.OpenFromFile("c:\temp", 0) ' Connect to tool - you need to change the toolbox name and model name Dim pGPToolBox As IGPToolbox Set pGPToolBox = pToolboxWorkspace.OpenToolbox("myToolbox.tbx") Dim pGPTool As IGPTool Set pGPTool = pGPToolBox.OpenTool("mdExplodeToSingleRoutes") ' Run tool Dim pGPToolCommandHelper As IGPToolCommandHelper Set pGPToolCommandHelper = New GPToolCommandHelper pGPToolCommandHelper.SetTool pGPTool pGPToolCommandHelper.Invoke Nothing ' Destroy objects Set pToolboxWorkspaceFactory = Nothing Set pToolboxWorkspace = Nothing Set pGPToolBox = Nothing Set pGPTool = Nothing Set pGPToolCommandHelper = Nothing
pGPToolCommandHelper.SetTool pGPTool pGPToolCommandHelper.Invoke Nothing
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.