cgraham

PLS Help: Using VB6 to access Geoprocessing Object

Discussion created by cgraham on Jun 29, 2011
Latest reply on Jul 6, 2011 by Hornbydd
Good Morning,
having trouble moving a 9.2 tool to 9.3.1.  The code below works great on 9.2:

Public Sub subMakeLines(sAccum As String, sImpedAtt As String, sDefBreakVal As String, sOutPath As String, sNetworkPath As String, sFacilitySHPName As String, sOutName As String, sOutPolyName As String)
 
    Dim pGp As Object, pFLayer As IFeatureLayer2, pFClass As IFeatureClass
    Dim pDS As IDataset
    Dim sBarrierPath As String, sTempFolder As String, FSO As New FileSystemObject, sServiceAreaName As String

183:     frmExportFeaturesToSHP.lbStatus = "Processing: " & Globals.g_iFeatNum & " of " & Globals.g_iFeatCount & " Facilities!"
184:     frmExportFeaturesToSHP.Refresh
'185:     sServiceAreaName = "LineServiceArea_" & Globals.g_iFeatNum
186:     sServiceAreaName = "LineServiceArea"
187:     Set pGp = CreateObject("esriGeoprocessing.GpDispatch.1")
188:     pGp.OverwriteOutput = 1
189:     pGp.Toolbox = "C:\Program Files\ArcGIS\ArcToolbox\Toolboxes\Network Analyst Tools.tbx"
190:     pGp.MakeServiceAreaLayer_na sNetworkPath, sServiceAreaName, sImpedAtt, "TRAVEL_FROM", sDefBreakVal, g_sPolyType, g_sMultiFacOptions, g_sOverlapType, g_sLineType, g_sOverlapTypeLines, g_sSplitLinesAtSrvAreaBreak, g_sExcludedSources, sAccum, "ALLOW_UTURNS", "", g_sTrimPoly, g_sTrimThres, "LINES_SOURCE_FIELDS"


But at 9.3.1 it doesn't work.  We think the issue is the way we are initializing the pGp

I think that I need to do something along the lines of replacing line 187 with:

187:     import arcgisscripting
188:     pGp = arcgisscripting.create(9.2)


Is this roughly how it is done?  Would it be 9.2 b/c that's the version I have on the development machine? or would I use 9.3 as that is the version on the target/testing machine.

Many thanks in advance for any and all suggestions.

Take care,
C

Outcomes