Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to execute one of my tools (which I created with Model Builder). I can execute a built-in tool by this code, but when I change the tool name with Model Tool Names it doesn't work.

I gathered information about referencing a new *.tbx file into a VB.Net project but it doesn't work properly. (When I use 'ArcGIS Toolbar Reference', nothing happens.)
Please help me.

This is my code for built-in tools:

Public Function CreateTempFileGDB() As Boolean

    Dim GP As ESRI.ArcGIS.Geoprocessor.Geoprocessor = Nothing
    GP = New ESRI.ArcGIS.Geoprocessor.Geoprocessor()

    GP.OverwriteOutput = True

    Dim parameters As IVariantArray = New VarArray

        GP.Execute("CreateFileGDB_management", parameters, Nothing)
    Catch ex As Exception
        Return False
    End Try

    Return True

End Function
share|improve this question
You need a reference for "ArcGIS Toolbox", and not ArcGIS Toolbar! Please refer the ESRI walkthrough – ujjwalesri Jun 28 '11 at 7:35
similar question here: – Jakub Jun 28 '11 at 11:42
up vote 5 down vote accepted

As @ujjwalesri pointed out, you need a reference to the toolbox. Here is an example that works for me:

Dim gp_msg As String = ""
Dim pGp As ESRI.ArcGIS.Geoprocessing.IGeoProcessor
Dim pResult As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult
Dim pParamArray As ESRI.ArcGIS.esriSystem.IVariantArray
Dim minZ As Double
Dim MaxZ As Double
Dim TinPath As String
Dim VolumeInterval As Double
Dim loopValue As Integer
Dim LoopElevationLevel As Double

TinPath = InputBox("Enter Path to the TIN:")

MaxZ = InputBox("Enter maximum elevation plane height starting value: ", "Maximum Plane Height - Custom Value", Math.Round(MaxZ))

minZ = InputBox("Enter minimum elevation: ", "Adjust Minimum Elevation", Math.Round(minZ))

VolumeInterval = InputBox("Enter INTERVAL:", "Volume Elevation Calculation Interval", 1)

loopValue = (MaxZ - minZ) / VolumeInterval

pGp = New ESRI.ArcGIS.Geoprocessing.GeoProcessor

pGp.OverwriteOutput = True

'Add the custom toolbox containing the model tool
pGp.AddToolbox("C:\Users\User\AppData\Roaming\ESRI\Desktop10.0\ArcToolbox\My Toolboxes\Toolbox.tbx")

LoopElevationLevel = MaxZ
Do Until LoopElevationLevel < minZ

    'Create the Parameter array (every iteration within loop - elevation changes)
    pParamArray = New ESRI.ArcGIS.esriSystem.VarArray

    'Populate array of parameters
    pParamArray.Add(TinPath) 'TIN
    pParamArray.Add(LoopElevationLevel) 'elevation

    'Execute the Model tool
    pResult = pGp.Execute("VolumeBellow", pParamArray, Nothing)

    gp_msg = gp_msg & ReturnMessages(pResult) & Chr(13)

    LoopElevationLevel = LoopElevationLevel - VolumeInterval             
share|improve this answer
Thank you very much – hassan vaezi Jun 29 '11 at 10:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.