+ Reply to Thread
Results 1 to 3 of 3

Thread: List Toolbox then Run

  1. #1
    Shaun Weston
    Join Date
    Jul 2010
    Posts
    322
    Points
    30
    Answers Provided
    4


    0

    Default List Toolbox then Run

    I'm trying to figure out how to call a tool from another tool in python. In my python script of got something similar to the code below to get a list of all tools and I basically want the script to run them all automatically, but can't figure out how. So basically what is going to happen is someone will create a new tool in the toolbox and this will automatically be added to the process and run automatically without having to alter the code.

    So my question is does anyone know how to automatically run a custom python tool? I can get a list of the tools in the toolbox, just not sure how to get them to run automatically.


    Code:
    import arcpy
    # Create a list of the conversion tools#
    tools = arcpy.ListTools("*_conversion")
    # Loop through the list and print each tool's usage#   
    e.g., 'Usage: merge <inputs;inputs...> <output> {field_mappings}'#
    for tool in tools:    
    print arcpy.Usage(tool)
    Shaun Weston | GIS Consultant | GIS Professional Services | Eagle Technology Group Ltd (Esri New Zealand Distributor) | email: shaun_weston@eagle.co.nz

  2. #2
    Joel Calhoun
    Join Date
    Apr 2010
    Posts
    133
    Points
    32
    Answers Provided
    2


    0

    Default Re: List Toolbox then Run

    If you need to pass parameters to your other tools you might want to take a look at this thread:

    http://gis.stackexchange.com/questio...-python-script

  3. #3
    Shaun Weston
    Join Date
    Jul 2010
    Posts
    322
    Points
    30
    Answers Provided
    4


    0

    Default Re: List Toolbox then Run

    Thanks that is helpful, but that post does get a bit complicated and hard to follow. I've got a solution that is working, but I'd like to be able to do one more thing and that is dynamically name a tool from python code. So I import a toolbox in python then I've got this line:

    arcpy.SelectProperty_toolbox(valuationID,"","",buffer,"")

    and "SelectProperty" is the name of the script. I want this name to be generated dynamically from the code. So if I could have that bit as a variable like this:

    arcpy.{variable}_toolbox(valuationID,"","",buffer,"")

    that would be great, but don't know how to do it?
    Shaun Weston | GIS Consultant | GIS Professional Services | Eagle Technology Group Ltd (Esri New Zealand Distributor) | email: shaun_weston@eagle.co.nz

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts