joshuamoloney

80004005 Error Collect Events with Render script

Discussion created by joshuamoloney on Nov 16, 2011
Greetings,

I have the following script which integrates points then collects events with render. Problem is the collect events with render part causes a 80004005 error (unspecified). Could you please have a look at my script and let me know where I have gone wrong? The Integrate part (with user tolerance) works fine, it is just the last collect event with render part that fails.

' Create the Geoprocessor object
set gp = WScript.CreateObject("esriGeoprocessing.GPDispatch.1")

' Load required toolboxes...
gp.AddToolbox "D:/ArcGIS/ArcToolbox/Toolboxes/Spatial Statistics Tools.tbx"
gp.AddToolbox "D:/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx"




'setup a dialog box to get the shapefile
'dialog box
Dim ObjFSO, InitFSO

' create an instance of the File Browser
Set ObjFSO = CreateObject("UserAccounts.CommonDialog")

'setup the File Browser specifics
ObjFSO.Filter = "Shapefiles|*.shp|Text Files|*.txt|All Files|*.*"
ObjFSO.FilterIndex = 1
ObjFSO.InitialDir = "D:\Data"


' show the file browser and return the selection (or lack of) to InitFSO
InitFSO = ObjFSO.ShowOpen

If InitFSO = False Then
    Wscript.Echo "Script Error: Please select a shapefile next time!"
    Wscript.Quit
Else
     TheShapefile = objfso.filename
 Output_Features = left(TheShapefile,len(TheShapefile)-4) & "_integrated.shp"
End If




'get the fodler name for later
theFolder = left(theshapefile,instrrev(theshapefile,"\")-1)




'get the actual shapefile name for later use
Fname = left(right(theshapefile, len(theshapefile) - instrrev(theshapefile,"\")),len(right(theshapefile, len(theshapefile) - instrrev(theshapefile,"\")))-4)


'get the tolerance and check if it is a number

a = inputbox("What tolerance would you like?")

if not isnumeric(a) then
 msgbox "Tolerance must be a number...quitting",vbcritical,"Error"
 wscript.quit
elseif not len(a) > 0 then
 msgbox "Tolerance must be a number...quitting",vbcritical,"Error"
 wscript.quit
end if 



'create the layer and shapefile names for the collect events with render

Output_Layer_File = left(TheShapefile,len(TheShapefile)-4) & "_" & a & "_metres"
Output_Weighted_Point_Feature_Class = left(TheShapefile,len(TheShapefile)-4) & "_" & a & "_metres.shp"


'integrate vars
a = a & " Meters"
b = theshapefile & " #"


'create a copy of the shapefile in case an error is made
set FSO = wscript.createobject("scripting.filesystemobject")
set FF = fso.getfolder(thefolder)
 for each file in FF.files
  if left(file.name,len(file.name)-4) = Fname then
   fso.copyfile file.name, left(file.name,len(file.name)-4) & "_backup." & right(file.name,3)
  end if
 next
   

' Process: Integrate...
gp.Integrate_management b, a


' Process: Collect Events with Rendering...
gp.CollectEventsRendered_stats theshapefile, Output_Layer_File, Output_Weighted_Point_Feature_Class '<---------------this is where the error occurs

msgbox "Success!"


Thanks!

Outcomes