There is any possible to open a script in a Toolset by GPToolDialog()?

381
3
Jump to solution
07-24-2017 07:04 AM
ViniciusCruvinel_Rego
New Contributor

I need to open a Python Script using GPToolDialog(), but the script is in a Toolset, not in the Toolbox main path.

I tried many ways to solve but do not work, examples:

Example 1:

pythonaddins.GPToolDialog(r'Path to Toolbox\Toolset', 'Script')

Example 2:

pythonaddins.GPToolDialog(r'Path to Toolbox', 'Toolset\Script')

No one ot the examples works.

0 Kudos
1 Solution

Accepted Solutions
ViniciusCruvinel_Rego
New Contributor

Alexander,

Note that I created a Toolset into a Toolbox. I realize that  GPToolDialog() calls the script name, even the .py are in or out any Toolset. If my new tool box goes to

Toolbox > Toolset > .py (script)

I can use your code:

import arcpy
import pythonaddins

pythonaddins.GPToolDialog(r'D:\Toolbox.tbx','.py (script, just the name)')‍‍‍‍

This code will call the Script name in the Toolbox, independent the location in any toolset. The name is the key.

Many thanks for the help!

View solution in original post

3 Replies
AlexanderBrown5
Occasional Contributor II

Vinicius,

I created a tool box here: 

D:\Toolbox

I created a tool set named "Tools" and I added a simple script to the toolbox and named it "test2."

Here is the syntax that opens that script in a GP dialog:

import arcpy
import pythonaddins

pythonaddins.GPToolDialog(r'D:\Toolbox.tbx','test2')

~Alex

ViniciusCruvinel_Rego
New Contributor

Alexander,

Note that I created a Toolset into a Toolbox. I realize that  GPToolDialog() calls the script name, even the .py are in or out any Toolset. If my new tool box goes to

Toolbox > Toolset > .py (script)

I can use your code:

import arcpy
import pythonaddins

pythonaddins.GPToolDialog(r'D:\Toolbox.tbx','.py (script, just the name)')‍‍‍‍

This code will call the Script name in the Toolbox, independent the location in any toolset. The name is the key.

Many thanks for the help!

View solution in original post

RebeccaStrauch__GISP
MVP Esteemed Contributor

Converted the discussion to a question so you can mark an answer as correct when resolved.  This helps others located the answer faster.