I created this code in hopes of sharing. One of my friends has Windows 8 and Arc 10.2.2, I have Windows 7 and Arc 10.2.1, it works great for me but fails for him below is his error message and below that is the code. Attached is the ode and all the pieces needed to make it run. Any help would be appreciated.
Error Message
Failed script SimpleStreetIndex...
Traceback (most recent call last):
File
"C:\Temp\WesStreetIndexer\StreetIndexCreator.py", line 91, in
<module>
field_map={'STNAME':fldName ,'PageName':gridField})
File
"c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\utils.py", line
181, in fn_
return
fn(*args, **kw)
File
"c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\mapping.py",
line 515, in ExportReport
return
report_source._arc_object.ExportReport(*gp_fixargs((report_layout_file,
output_file, dataset_option, report_title, starting_page_number, page_range,
report_definition_query, extent, field_map), True))
RuntimeError: Error in generating report
Failed to execute (SimpleStreetIndex).
Failed at Thu May 21 12:12:18 2015 (Elapsed Time: 1
minutes 0 seconds)
Code
# -*- coding: utf-8 -*- # --------------------------------------------------------------------------- # Auhor Wes Miller # Description: # Selects streets that intersect with grid, creates a street index and exports to pdf # --------------------------------------------------------------------------- # Import arcpy module import arcpy,os arcpy.env.overwriteOutput = True # Local variables: InputStreets = arcpy.GetParameterAsText(0) InputGrid = arcpy.GetParameterAsText(1) fldName = arcpy.GetParameterAsText(2) gridField = arcpy.GetParameterAsText(3) indexdoc = arcpy.GetParameterAsText(4) indexname = arcpy.GetParameterAsText(5) indexLayout = arcpy.GetParameterAsText(6) #StreetsthatIntersectGrid = "RoadSegment_Layer" DissolvedStreets = "in_memory\\dissolveStreets" Streets = "Streets_lyr" Grid = "Grid_lyr" outfc = "in_memory\\joinIndex" # Process: Make Feature Layer arcpy.MakeFeatureLayer_management(InputStreets, Streets) arcpy.AddMessage("Streets layer made") # Process: Make Feature Layer (2) arcpy.MakeFeatureLayer_management(InputGrid, Grid) arcpy.AddMessage("Grid layer made") # Process: Select Layer By Location arcpy.SelectLayerByLocation_management(Streets, "INTERSECT", Grid, "", "NEW_SELECTION") arcpy.AddMessage("Streets selection layer made") # Process: Dissolve arcpy.AddMessage("Process: Dissolve") arcpy.Dissolve_management(Streets, DissolvedStreets, fldName, "", "MULTI_PART", "DISSOLVE_LINES") if indexname.find('.')<0: arcpy.AddMessage("when you don't select a file type pdf is default") indexname = indexname+'.pdf' indexdoc = os.path.join(indexdoc,indexname) hmpath = os.path.realpath(__file__) h,t = os.path.split(hmpath) mxdDoc = os.path.join(h,"StreetIndexCreatorMapDoc.mxd") mxd = arcpy.mapping.MapDocument(mxdDoc) df = arcpy.mapping.ListDataFrames(mxd, "*")[0] # Create a new fieldmappings and add the two input feature classes. fieldmappings = arcpy.FieldMappings() fieldmappings.addTable(DissolvedStreets) fieldmappings.addTable(InputGrid) jField = fieldmappings.findFieldMapIndex(gridField) fieldmap = fieldmappings.getFieldMap(jField) fieldmap.mergeRule = "join" fieldmap.joinDelimiter = "," fld_length = fieldmap.outputField fld_length.length = 4000 if fieldmap.outputField.type.lower() != 'string': fld_length.type = 'String' fieldmap.outputField = fld_length fieldmappings.replaceFieldMap(jField, fieldmap) arcpy.AddMessage("Process: Spatial Join") # Process: Spatial Join arcpy.SpatialJoin_analysis(DissolvedStreets, InputGrid, outfc, "#", "#", fieldmappings) addLayer = arcpy.mapping.Layer(outfc) arcpy.mapping.AddLayer(df, addLayer, "BOTTOM") if indexLayout == "11 X 17 Landscape": rpttemplate = os.path.join(h,"reporttemplate11X17.rlf") else: rpttemplate = os.path.join(h,"reporttemplate.rlf") arcpy.AddMessage("Creating Report") lyr = arcpy.mapping.ListLayers(mxd, "joinIndex", df)[0] arcpy.mapping.ExportReport(lyr, rpttemplate, indexdoc, report_title="Street Index", field_map={'STNAME':fldName ,'PageName':gridField}) del mxd