Where is the the Model Functions toolbox?

3528
6
11-16-2017 04:38 PM
PaulHuffman
Occasional Contributor III

I was playing around, testing the iterative and looping features of Model Builder in 10.5,  to see if they were now complete enough and easier for me to understand than looping in python.  I made a little model that selects a few rasters with a wildcard out of a workspace with Iterate Rasters and then changes the projection, writing the output to a new folder and using the %Name% variable to create similar names on the output files.  I got the model to run,  then I exported to python to see how the iteration was handled by the export.  Well, the python script doesn't contain any of the iteration stuff.  I thought it might run one time but it doesn't.  Seems like the export to python inserted a couple lines

# Load required toolboxes
arcpy.ImportToolbox("Model Functions")

But at run time,  IDLE doesn't know the path to this toolbox.  Where do I find it?

Traceback (most recent call last):  File "G:\elevation\lidar2010\Orthophotos\testiterativemodels\iterateRaster.py", line 14, in <module>    arcpy.ImportToolbox("Model Functions")  File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\__init__.py", line 125, in ImportToolbox    return import_toolbox(input_file, module_name)  File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\toolbox_code.py", line 452, in import_toolbox    toolbox = gp.createObject("Toolbox", tbxfile)  File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\geoprocessing\_base.py", line 381, in createObject    self._gp.CreateObject(*gp_fixargs(args, True)))IOError: The toolbox file Model Functions was not found.
Tags (2)
0 Kudos
6 Replies
DanPatterson_Retired
MVP Emeritus

I couldn't locate it either and it isn't in this folder path

C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcToolbox\Toolboxes

So where do you save your toolboxes? 

Just do a windows search it is probably in your user path like here

C:\Users\this_B_you\AppData\Roaming\ESRI\Desktop10.5\ArcToolbox\My Toolboxes

0 Kudos
PaulHuffman
Occasional Contributor III

I searched the whole C drive for Model Functions.tbx, but didn't find it.  Wouldn't that be the search term?  Is the space in the file name a problem?

I don't think it is one of my toolboxes.  I didn't see Model Functions toolbox used in my little model, so I think it is strange that the export from model to Python comes up with this required load. 

0 Kudos
SteveLynch
Esri Regular Contributor

The toolbox could be inside a file geodatabase.

PaulHuffman
Occasional Contributor III

Oh, yeah.  So how would I search for toolboxes inside a file geodatabase?

0 Kudos
DanPatterson_Retired
MVP Emeritus

Pro link... but checking the aprx in the mapping module has a 'default toolbox' check, if it is there,,

http://pro.arcgis.com/en/pro-app/arcpy/mapping/arcgisproject-class.htm

0 Kudos
PaulHuffman
Occasional Contributor III

Oh,  I was being mislead by the error message.  The problem is the export to Python of this model that uses Iterate Rasters gives me a script that tries to call arcpy.IterateRasters when the tool help clearly says "This tool is intended for use in ModelBuilder and not in Python scripting." And also seems to want to require a toolbox that doesn't exist. 

All I was interested in testing was how Export to Python in Model Builder handles the iterative tools, and I guess the answer is "not well at all".  I would have to rewrite this script to create a list of files and loop through the list using python tools. 

# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# iterateRaster.py
# Created on: 2017-11-16 16:02:06.00000
#   (generated by ArcGIS/ModelBuilder)
# Description: 
# Testing advanced Model Builder Techniques
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy

# Load required toolboxes
arcpy.ImportToolbox("Model Functions")


# Local variables:
v_Input_photos_workspace_ = "%Input photos workspace%"
K_1473E616N_tif = "G:\\elevation\\lidar2010\\Orthophotos\\K_1473E621N.tif"
v_Name__Project_tif = "G:\\elevation\\lidar2010\\Orthophotos\\testiterativemodels\\Output\\%Name%_Project.tif"
Input_photos_workspace = "G:\\elevation\\lidar2010\\Orthophotos"
Name = "K_1473E621N.tif"

# Process: Iterate Rasters
arcpy.IterateRasters_mb(v_Input_photos_workspace_, "K_1473*", "TIF", "NOT_RECURSIVE")

# Process: Project Raster
arcpy.ProjectRaster_management(K_1473E616N_tif, v_Name__Project_tif, "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],VERTCS['WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PARAMETER['Vertical_Shift',0.0],PARAMETER['Direction',1.0],UNIT['Meter',1.0]]", "BILINEAR", "1.67194671764969E-06 1.67194671764969E-06", "WGS_1984_(ITRF00)_To_NAD_1983", "", "PROJCS['NAD_1983_StatePlane_Washington_South_FIPS_4602_Feet',GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Lambert_Conformal_Conic'],PARAMETER['False_Easting',1640416.666666667],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-120.5],PARAMETER['Standard_Parallel_1',45.83333333333334],PARAMETER['Standard_Parallel_2',47.33333333333334],PARAMETER['Latitude_Of_Origin',45.33333333333334],UNIT['Foot_US',0.3048006096012192]]")

‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍