Getting Automation Error on GP call to Erase.

476
1
Jump to solution
02-19-2013 11:15 AM
CraigGraham
New Contributor III
Good Afternoon,
I am running across an issue with using the geoprocessor with Erase.  I have used this style (below) many times, and with commands that require much more complex arguments.  I can't see what I'm doing wrong.  Any help or suggestions appreciated. 

    Set pGP = CreateObject("esriGeoprocessing.GpDispatch.1")     pGP.OverwriteOutput = 1     If fso.FolderExists("C:\Program Files\ArcGIS") Then         pGP.Toolbox = "C:\Program Files\ArcGIS\ArcToolbox\Toolboxes\Analysis Tools.tbx"     Else         pGP.Toolbox = "C:\Program Files(x86)\ArcGIS\ArcToolbox\Toolboxes\Analysis Tools.tbx"     End If MsgBox "subErase - (In, Erase, Out) = " & vbNewLine & sInputLayer & vbNewLine & sEraseLayer & vbNewLine & sOutputLayer     pGP.Erase_Analyses sInputLayer, sEraseLayer, sOutputLayer     Set pGP = Nothing  


It is failing at the call to the command.  The msgbox shows that all three variables are set to valid paths.  I ran the command in the command line interface, and no problem.

I'm testing on Win7 64, ArcGIS 9.3.1, ArcINFO license.

Thanks in advance for any assistance.

Take care,
Craig
0 Kudos
1 Solution

Accepted Solutions
CraigGraham
New Contributor III
(EDITED)

I've tried another method, and initially it didn't work, then I took a break, and saw a couple of silly mistakes...

Now this works fine:

    Dim fso As New FileSystemObject     Dim pGp As IGeoProcessor     Dim sInputLayer As String, sOutputLayer As String     Dim pResult As IGeoProcessorResult     Dim pParamArray As IVariantArray 833:     Set pParamArray = New esriSystem.VarArray 839:     Set pGp = New GeoProcessor 840:     pGp.OverwriteOutput = True 843:     If fso.FolderExists("C:\Program Files\ArcGIS") Then 844:         pGp.AddToolbox "C:\Program Files\ArcGIS\ArcToolbox\Toolboxes\Analysis Tools.tbx" 846:     Else 847:         pGp.AddToolbox "C:\Program Files(x86)\ArcGIS\ArcToolbox\Toolboxes\Analysis Tools.tbx" 849:     End If 850:     pGp.AddOutputsToMap = False 851:   pParamArray.Add sInputLayer 852:   pParamArray.Add sOutputLayer 853:   pParamArray.Add iBufferDistance 854:   pParamArray.Add "OUTSIDE_ONLY" 856:   Set pResult = pGp.Execute("Buffer", pParamArray, Nothing) 859:     Set pGp = Nothing   Exit Sub CustomErrorHandler: 862:     MsgBox "Error in subBuffer2:" & vbNewLine & "Line " & GetErrorLineNumberString(Erl) & vbNewLine & "Error Number: " & Err.Number & vbNewLine & "Error Source: " & Err.Source & vbNewLine & "Issue: " & Err.Description


Still it is strange that the older method (in first post) has worked fine with things like network analyst, spatial analyst, other standard operations (new Featureclass, clip....) without a problem, and they use the exact same setup, and sam version of ArcGIS.... 

Cheers,
Craig

View solution in original post

0 Kudos
1 Reply
CraigGraham
New Contributor III
(EDITED)

I've tried another method, and initially it didn't work, then I took a break, and saw a couple of silly mistakes...

Now this works fine:

    Dim fso As New FileSystemObject     Dim pGp As IGeoProcessor     Dim sInputLayer As String, sOutputLayer As String     Dim pResult As IGeoProcessorResult     Dim pParamArray As IVariantArray 833:     Set pParamArray = New esriSystem.VarArray 839:     Set pGp = New GeoProcessor 840:     pGp.OverwriteOutput = True 843:     If fso.FolderExists("C:\Program Files\ArcGIS") Then 844:         pGp.AddToolbox "C:\Program Files\ArcGIS\ArcToolbox\Toolboxes\Analysis Tools.tbx" 846:     Else 847:         pGp.AddToolbox "C:\Program Files(x86)\ArcGIS\ArcToolbox\Toolboxes\Analysis Tools.tbx" 849:     End If 850:     pGp.AddOutputsToMap = False 851:   pParamArray.Add sInputLayer 852:   pParamArray.Add sOutputLayer 853:   pParamArray.Add iBufferDistance 854:   pParamArray.Add "OUTSIDE_ONLY" 856:   Set pResult = pGp.Execute("Buffer", pParamArray, Nothing) 859:     Set pGp = Nothing   Exit Sub CustomErrorHandler: 862:     MsgBox "Error in subBuffer2:" & vbNewLine & "Line " & GetErrorLineNumberString(Erl) & vbNewLine & "Error Number: " & Err.Number & vbNewLine & "Error Source: " & Err.Source & vbNewLine & "Issue: " & Err.Description


Still it is strange that the older method (in first post) has worked fine with things like network analyst, spatial analyst, other standard operations (new Featureclass, clip....) without a problem, and they use the exact same setup, and sam version of ArcGIS.... 

Cheers,
Craig
0 Kudos