Jump to content

Export selected report pages with script


Recommended Posts

Hello All!

I would like to export selected report pages with a script. I would like to export all pages except the last one.

I have some tries but did not find a working solution yet.

This is how my (not working) script looks like at the moment:

import gom


report_list = []
for num in range (0,len(gom.app.project.reports)-1):
    report_list.append("gom.app.project.reports[report " + str(num) + "]")

gom.script.report.export_pdf (
    file='C:/Users/tomori.m/Desktop/test.pdf',
    jpeg_quality_in_percent=100,
    reports= report_list )

 

Link to comment
https://qualityforum.zeiss.com/topic/839-export-selected-report-pages-with-script/
Share on other sites

You got the right idea. But you should not provide the "reports" parameter as a list of strings. Anyway, "gom.app.project.reports" already is some kind of list (iterable), so you can use python slices to select ranges (e.g. "[:-1]" for your case to get all but the last one).

The code working for me looks like:

import gom

gom.script.report.export_pdf (
    file='C:/Users/tomori.m/Desktop/test.pdf',
    jpeg_quality_in_percent=100,
    reports=gom.app.project.reports[:-1])

 

  • 1 month later...
×
×
  • Create New...