Hi Stacy,
Thanks for your help on this. The error I am receiving is as follows:
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute
'ExportPackageWEL_mytools'
Failed to execute (EastShorePermit).
I inserted the "try/except" clause like you said. The error no longer shows, however it just skips over the section where the trouble occurs. The script I am using is pretty long, but the trouble really only occurs in the very last block of code:
import arcpy
#Clears the rows in "Wells_New" and adds 1 new row
arcpy.AddMessage("The rows in 'Wells_New' feature class are being cleared")
arcpy.DeleteRows_management("Wells_New")
rows = arcpy.InsertCursor("Wells_New")
myrow = 1
while myrow <= 1:
row = rows.newRow()
myrow = myrow + 1
rows.insertRow(row)
del row
del rows
arcpy.AddMessage("The rows have been cleared")
#Linking script parameters entered in ArcGIS to
#Python Parameters in this script
arcpy.AddMessage("Linking script parameters entered in ArcGIS to Python Parameters in this script")
pR = arcpy.GetParameterAsText(0)
sT = arcpy.GetParameterAsText(1)
sB = arcpy.GetParameterAsText(2)
K = arcpy.GetParameterAsText(3)
X = arcpy.GetParameterAsText(4)
Y = arcpy.GetParameterAsText(5)
arcpy.AddMessage("The parameters you entered have been linked to python parameters in the script")
#Write the parameters to 'Wells_New'
arcpy.AddMessage("Write the parameters to 'Wells_New'")
rows = arcpy.UpdateCursor("Wells_New")
for row in rows:
row.PumpingRate = pR
row.ScreenTop = sT
row.ScreenBot = sB
row.LayerNumber = K
row.X = X
row.Y = Y
rows.updateRow(row)
del row
del rows
arcpy.AddMessage("The parameters you entered are being written to the 'Wells_New' feature class")
#Converts the Coordinates to a point
#Uses the SearchCursor to extract the X, Y values from "Wells_New"
arcpy.AddMessage("Creating Point from coordinates")
rows = arcpy.SearchCursor("Wells_New")
for row in rows:
xval = row.X
yval = row.Y
del row
del rows
#Creating Point from coordinates
point = arcpy.Point(xval, yval)
pointGeo = arcpy.PointGeometry(point)
arcpy
arcpy.AddMessage("A point has been created based on the coordinates you provided")
#Writes that point to the "SHAPE*" field in the "Wells_New" table.
arcpy.AddMessage("The point that was created is being assigned as the location of the new well")
rows = arcpy.UpdateCursor("Wells_New")
for row in rows:
row.SHAPE = pointGeo
rows.updateRow(row)
del row
del rows
arcpy.AddMessage("The location of the new well has been assigned")
#Determine the IJ index for the well
#Used to help determine value of IJK
arcpy.AddMessage("Determining 'IJ' indice for the new well")
arcpy.SelectLayerByLocation_management("Cell2D","INTERSECT","Wells_New")
rows = arcpy.SearchCursor("Cell2D")
for row in rows:
ijdex = row.IJ
del row
del rows
arcpy.SelectLayerByAttribute_management("Cell2D", "CLEAR_SELECTION")
arcpy.AddMessage("The 'IJ' indice is " + str(ijdex))
#Determine the values of I and J seperately
#Used in determining IJK
arcpy.AddMessage("Determining the values of I and J seperately")
rows = arcpy.SearchCursor("CellIndex", '[IJ]='+ str(ijdex))
for row in rows:
Ival = row.I
Jval = row.J
del row
del rows
arcpy.AddMessage("The value of the 'I' indice is " + str(Ival))
arcpy.AddMessage("The value of the 'J' indice is " + str(Jval))
#Number of Cells in the I, J, and K directions.
#Used in calculation of IJK
numi = 67
numj = 36
numk = 3
#Calculate the value of IJK
#Used for ahgw 'WEL' table
arcpy.AddMessage("Calculating the IJK indice")
K = int(K)
IJK = ((K - 1) * numi * numj )+(( Ival - 1 ) * numj ) + Jval
arcpy.AddMessage("The value of 'IJK' is " + str(IJK))
#Create a new blank row in the well table
arcpy.AddMessage("Creating a new blank row in the 'WEL' table")
rows = arcpy.InsertCursor("WEL")
myrow = 1
while myrow <= 1:
row = rows.newRow()
myrow = myrow + 1
rows.insertRow(row)
del row
del rows
arcpy.AddMessage("A new blank row has been created in the 'WEL' table")
#Write the appropriate values to the "WEL" table
arcpy.AddMessage("Writing values to the 'WEL' table")
arcpy.SelectLayerByAttribute_management("WEL", "NEW_SELECTION", ' is null')
rows = arcpy.UpdateCursor("WEL")
for row in rows:
row.Q = pR
row.IJK = IJK
arcpy.AddMessage("Writing Key Value to 'CELLGRP' field")
row.CELLGRP = -1
row.SPID = 1
row.Qfact = 1
row.IFACE = 0
rows.updateRow(row)
del row
del rows
arcpy.SelectLayerByAttribute_management("WEL","CLEAR_SELECTION")
arcpy.AddMessage("Values for new well have been written to the 'WEL' table")
#Import My tool Box to use several AHGW tools
arcpy.AddMessage("Importing a toolbox containing several AHGW tools that will be used")
arcpy.ImportToolbox("D:\GIS_Geodatabase\ES12.mdb\mytools", "mytools")
arcpy.AddMessage("The toolbox has been imported")
arcpy.AddMessage("Exporting the AGHW 'WEL' table to the MODFLOW '.wel' file")
# The code dies somewhere in here or at least I do not see the next 'AddMessage' that I programmed in
arcpy.mytools.ExportPackageWEL("WEL","CELLGRP","CBFlags","StressPeriods","DISVars","Params","D:\MODFLOW_WorkingFiles\EASTSHOR_MODFLOW\EASTSHOR.wel")
arcpy.AddMessage("The Table has been exported")
arcpy.AddMessage("Using AHGW tools to run MODFLOW")
arcpy.mytools.RunMODFLOW("C:\Program Files (x86)\Aquaveo\Arc Hydro Groundwater Toolkit\MF2K\mf2k_ahgw.exe", "D:\MODFLOW_WorkingFiles\EASTSHOR_MODFLOW\EASTSHOR.mfn")
arcpy.AddMessage("MODFLOW has finished")
arcpy.AddMessage("Importing the results of the MODFLOW model that are relevant to analysis")