dodgyshamrock

calling other scripts with arguments from a script tool

Discussion created by dodgyshamrock on Dec 19, 2011
Latest reply on Dec 19, 2011 by curtvprice
Ugh!  Still fairly new to Python and trying to figure this out on my own.  But I think I still don't quite "get" defining functions and calling functions.  Anyway, I've written a long script that allows a user to interactively add a point to a feature class and then it buffers the point and does a whole bunch of other things.  Now that I've gotten that to work, I would like the user to also be able to add a point using X,Y coordinates.  So my thought was to have 3 scripts.  The first would be where the user would choose which method they wanted to use to add the point (interactively or with XY coordinates).  This script would then call one of two others (1. the script to interactively add the point or 2. the script to add the point using XY coordinates).  This is what I have tried for the first script:

import ptInteractive
import ptXY

def main():
    try:
        method = arcpy.GetParameterAsText(0)
        if method == "Interactive":
            ptInteractive.main()
        elif method == "XYCoordinates":
            ptXY.main()

    except:
        tb = sys.exc_info()[2]
        tbinfo = traceback.format_tb(tb)[0]
        pymsg = "PYTHON ERRORS: \nTraceback info:\n" + tbinfo +  "\nError Info:\n" + str(sys.exc_info()[1])
        msgs = "ArcPy ERRORS: \n" + arcpy.GetMessages(2) + "\n"
        arcpy.AddError(pymsg)
        arcpy.AddError(msgs)

    return


I am trying to run this through script tools in ArcMap but I cannot get it to work.  It gives me an I/O Error and says that "Interactive" does not exist. 

Is there an argument I need to pass?  How do I get the boxes for the two subscripts to open in ArcMap so the user can choose the arguments?  Is this even possible? 

Thanks!

Amy Meehan
MDIFW
Bangor, Maine

Outcomes