Unable to complete operation. Error executing tool.: Traceback (most recent call last): File "<ags_folder>\PythonWebPrint.GPServer\extracted\v101\my_toolboxes\service.py", line 643, in <module> main() File "<ags_folder>\PythonWebPrint.GPServer\extracted\v101\my_toolboxes\service.py", line 634, in main (message, output_file, image_files) = execute(web_map_json, output_format, layout_template, layout_template2, georef_info, quality) File "<ags_folder>\PythonWebPrint.GPServer\extracted\v101\my_toolboxes\service.py", line 482, in execute staticLegend.sourceImage = legendPath File "c:\program files\arcgis\server\arcpy\arcpy\arcobjects\_base.py", line 87, in _set return setattr(self._arc_object, attr_name, cval(val)) IOError: Cannot set path based on current settings. Failed to execute (PythonWebPrint). Failed to execute (Python Web Print).
elements = arcpy.mapping.ListLayoutElements(mxd, 'PICTURE_ELEMENT', "StaticLegend") if len(elements) > 0: # Get the picture staticLegend = elements[0] if web_map_object.has_key("staticLegend"): legendPath = os.path.join(template_path, "legends", web_map_object["staticLegend"]) staticLegend.sourceImage = legendPath else: # Cannot actually delete things, so just move it off the page staticLegend.elementPositionX = -100
Solved! Go to Solution.
It shouldn't be an issue. I'd just sort of try some things at this point, one of which would be to save the image as a PNG. I'd also do some diagnostic messaging just in case:
if web_map_object.has_key("staticLegend"): legendPath = os.path.join(template_path, "legends", web_map_object["staticLegend"]) arcpy.AddMessage("Setting legend to {0} -- is file? {1}".format(legendPath, os.path.isfile(legendPath))) staticLegend.sourceImage = legendPath
Does the map document have data-driven pages enabled? Is the picture element set to either 1) use a field as the image path or 2) use an attachment as the image source? If so, that is the reason you can't set the image path.
Hmm. The only way other you'd get that particular error message is if arcgis either could not find or could not open the image file.
if web_map_object.has_key("staticLegend"): legendPath = os.path.join(template_path, "legends", web_map_object["staticLegend"]) arcpy.AddMessage("Setting legend to {0} -- is file? {1}".format(legendPath, os.path.isfile(legendPath))) staticLegend.sourceImage = legendPath
It shouldn't be an issue. I'd just sort of try some things at this point, one of which would be to save the image as a PNG. I'd also do some diagnostic messaging just in case:
if web_map_object.has_key("staticLegend"): legendPath = os.path.join(template_path, "legends", web_map_object["staticLegend"]) arcpy.AddMessage("Setting legend to {0} -- is file? {1}".format(legendPath, os.path.isfile(legendPath))) staticLegend.sourceImage = legendPath