My script works fine, but I am not able to export .pdf file from a report generated. This is my code:
import arcpy
inputFC = arcpy.GetParameterAsText(0)
outputFC = arcpy.GetParameterAsText(1)
matricula = arcpy.GetParameterAsText(2)
query = """ "MATRICULA" LIKE '%s'""" %matricula
arcpy.env.workspace = "C:/Prueba/arcpy"
arcpy.MakeFeatureLayer_management(inputFC,"Tramos_LAT_layer")
arcpy.SelectLayerByAttribute_management("Tramos_LAT_layer","NEW_SELECTION",query)
arcpy.CopyFeatures_management("Tramos_LAT_layer",outputFC)
# Following I try to export report from outputFC
# RLF
plantilla = "PLANTILLA_INFORMES.rlf"
# PDF
pdf = "zz_salida_report.pdf"
# Exportamos Report
arcpy.mapping.ExportReport(outputFC,plantilla,pdf)
I also tested another option, I created a layer file, but it didn ́t work either:
lyr = arcpy.mapping.Layer(outputFC)
arcpy.mapping.ExportReport(lyr,plantilla,pdf)
I have checked all post about this issue, although I don't understand why my script doesn't work.
-
Have you tried using full paths to point to PLANTILLA_INFORMES.rlf and also for the output zz_salida_report.pdf? The documented examples all use fully qualified paths - resources.arcgis.com/en/help/main/10.2/index.html#//…Clubdebambos– Clubdebambos2017年02月23日 13:08:33 +00:00Commented Feb 23, 2017 at 13:08
-
The documentation also says it must reference a Layer or TableView object. A Layer object can either be a reference to a .lyr file or a layer in a map document. The outputFC should be in an mxd and a reference made to it. See the examples in the link aboveClubdebambos– Clubdebambos2017年02月23日 13:25:39 +00:00Commented Feb 23, 2017 at 13:25
-
Thank you so much. You are right, I have used full paths to point to "file".rlf and "file".pdf and it works !! I really appreciate your help.Antonio J. Rguez Garrido– Antonio J. Rguez Garrido2017年02月23日 16:15:19 +00:00Commented Feb 23, 2017 at 16:15
-
However, I still don't understand why didn't work it, because I used a workspace (arcpy.env.workspace = "C:/Prueba/arcpy"). ThanksAntonio J. Rguez Garrido– Antonio J. Rguez Garrido2017年02月23日 16:19:58 +00:00Commented Feb 23, 2017 at 16:19
-
Excellent, I have added it as an answer if you can give it a green tick of approval. I tried to find info for workspace and the tool but couldn't find any. It was only when I saw the examples with full paths that I thought that workspace might not work for the input and output of the toolClubdebambos– Clubdebambos2017年02月23日 16:24:14 +00:00Commented Feb 23, 2017 at 16:24
1 Answer 1
The documented examples for ExportReport use full paths for the report_layout_file and output_file parameters (2nd and 3rd parameters)
Change the code to reflect this
# RLF
plantilla = "full_path/PLANTILLA_INFORMES.rlf"
# PDF
pdf = "full_path/zz_salida_report.pdf"