Quantcast
Channel: Forums - ArcObjects SDKs
Viewing all articles
Browse latest Browse all 1374

Geoprocessing Tool Failing in VBA Code

$
0
0
I have the code (VBA) below hooked up to a button in ArcMap 10.0. The first time it is used it runs successfully. If I try to run it a second time, the Intersect tool doesn't create the in_memory featureclass as expected and the code fails when it tries to run CalculateField. Any ideas as to why?

Code:

    (Identify and validate pLayer & pLayer2)
    ...
    'Intersect the PLU/soils data with the Sections
    Dim pGp As IGeoProcessor
    Set pGp = New GeoProcessor
    pGp.OverwriteOutput = True
   
    Dim pParams As IVariantArray
    Set pParams = New VarArray
   
    Dim PTS As String
    PTS = "PlanningToolSoils"
   
    pParams.RemoveAll
    pParams.Add pLayer.Name & "; " & pLayer2.Name
    pParams.Add "in_memory\" & PTS
    pParams.Add "NO_FID"
    pGp.Execute "Intersect_Analysis", pParams, Nothing
   
    'Update the CALCACRES Column
    pParams.RemoveAll
    pParams.Add PTS
    pParams.Add "CALCACRES"
    pParams.Add "!shape.area@acres!"
    pParams.Add "PYTHON"
    pGp.Execute "CalculateField_management", pParams, Nothing
   
    'Export the tabular portion of the FeatureClass to C:\temp\data.dbf
    pParams.RemoveAll
    pParams.Add PTS
    pParams.Add "C:\temp\Data.dbf"
    pGp.AddOutputsToMap = False
    pGp.Execute "CopyRows_management", pParams, Nothing
   
    'Delete the temporary featureclass
    pMap.DeleteLayer FindLayerByName(pMap, PTS) 'A home-built function that searches for an ILayer in the TOC
    pParams.RemoveAll
    pParams.Add "in_memory\" & PTS
    pGp.Execute "Delete_management", pParams, Nothing


Viewing all articles
Browse latest Browse all 1374

Trending Articles