Okay I figured out a workaround for this.arcpy.ImportToolbox("Path to Toolbox")arcpy.gp.Toolbox = "Path to Toolbox"arcpy.gp.ToolName()Using this method I can import the toolbox and run it as many times as I want. Not sure why it works though.
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute '__metaclass__'
import arcpy if u"mytools" not in arcpy.ListToolboxes(): arcpy.ImportToolbox("D:\GIS_Geodatabase\ES12.mdb\mytools", "mytools") arcpy.AddMessage("The toolbox has been imported") else: arcpy.AddMessage("Toolbox already present, skipping import") arcpy.mytools.ExportPackageWEL("WEL","CELLGRP","CBFlags","StressPeriods","DISVars","Params","D:\MODFLOW_WorkingFiles\EASTSHOR_MODFLOW\EASTSHOR.wel")
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 rowdel rowsarcpy.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 toolsarcpy.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 inarcpy.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")
import arcpy try: arcpy.ImportToolbox("D:\GIS_Geodatabase\ES12.mdb\mytools", "mytools") arcpy.mytools.ExportPackageWEL("WEL","CELLGRP","CBFlags","StressPeriods","DISVars","Params","D:\MODFLOW_WorkingFiles\EASTSHOR_MODFLOW\EASTSHOR.wel") except: print arcpy.GetMessages(2)
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.