Skip to content

Instantly share code, notes, and snippets.

@danmaps
Created May 11, 2016 19:47
Show Gist options
  • Save danmaps/9754eb745a63e231090318e92a7242d8 to your computer and use it in GitHub Desktop.
Save danmaps/9754eb745a63e231090318e92a7242d8 to your computer and use it in GitHub Desktop.
def createScript():
import os
tbx_path = r"D:\sfe\MOTOROLA.tbx"
tbx_alias = "MOTOROLA"
modelname = "Model1-frequency"
outputLocation = r"D:\sfe\MOTOROLA\PYTHONS"
outScript = open(os.path.join(outputLocation, "outScript.py"), "w")
outScript.write("import arcpy\n")
outScript.write('arcpy.ImportToolbox(r"' + tbx_path + '")\n')
outScript.write('print "toolbox imported successfully"\n')
outScript.write("arcpy." + modelname + "_" + tbx_alias + "()\n")
outScript.write('print "model completed successfully"\n')
outScript.close()
if __name__ == '__main__':
createScript()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment