[Ma...] Posted July 12, 2022 Share Posted July 12, 2022 I'm new to GOM and Python both; however, I needed a way to generate individual reports for each mesh in a stage. Here is the script I came up with that works for me. I would welcome any feedback if anyone, especially the Pyhtonistas, wants to try it or critique it. #-------------------------------------------------------------------------------------- # This script will create individual reports for each mesh in a stage. # The report name will be the same as the mesh it's genreated from. #-------------------------------------------------------------------------------------- import gom gom.script.sys.recalculate_project () for i in range(len(gom.app.project.stages)): # Iterates through all meshes in the stage. gom.script.sys.show_stage (stage=gom.app.project.stages[i]) gom.script.sys.set_stage_as_reference (stage=gom.app.project.stages[i]) gom.script.sys.switch_to_report_workspace () report_pages = [] # Creates a list of all report page indexes for selected mesh. for t in gom.app.project.reports: report_pages.append(t) gom.script.report.update_report_page ( pages=report_pages, used_alignments='report', used_digits='report', used_legends='report', used_stages='current', used_units='report') gom.script.report.export_pdf ( export_all_reports=True, file='C:/Users/ZEISS-CMM/Documents/GOM/Reports/'+str(gom.app.project.stage)+'.pdf', jpeg_quality_in_percent=100) Link to comment Share on other sites More sharing options...
[Ke...] Posted July 15, 2022 Share Posted July 15, 2022 Hi Mark, Here's what i use. The difference is it only picks up the active stages, and it prompts for a save location. File name comes from the name/title of the first report page, so if you add a stage reference into that then you'll end up with unique names. # -*- coding: utf-8 -*- # Exports reports for acive stages import gom RESULT=gom.script.sys.execute_user_defined_dialog (content='<dialog>' \ ' <title>Choose Folder</title>' \ ' <style></style>' \ ' <control id="OkCancel"/>' \ ' <position></position>' \ ' <embedding></embedding>' \ ' <sizemode></sizemode>' \ ' <size height="120" width="305"/>' \ ' <content columns="1" rows="1">' \ ' <widget row="0" column="0" rowspan="1" columnspan="1" type="input::file">' \ ' <name>folder</name>' \ ' <tooltip></tooltip>' \ ' <type>directory</type>' \ ' <title>Choose Destination</title>' \ ' <default>C:/Users/user/Documents</default>' \ ' <limited>false</limited>' \ ' <file_types/>' \ ' <file_types_default></file_types_default>' \ ' </widget>' \ ' </content>' \ '</dialog>') foldertxt=(RESULT.folder + '/') print(foldertxt) for i in range(len(gom.app.project.stages)): if (gom.app.project.stages[i].is_active): gom.script.sys.show_stage (stage=gom.app.project.stages[i]) page_list = list(gom.app.project.reports) gom.script.report.update_report_page ( pages=(page_list), used_alignments='report', used_digits='report', used_legends='report', used_stages='current', used_units='report') filetxt=(gom.app.project.reports[0].name) gom.script.report.export_pdf ( export_all_reports=True, file=(foldertxt + filetxt + '.pdf'), jpeg_quality_in_percent=80, max_dpi=85) RESULT=gom.script.sys.execute_user_defined_dialog (content='<dialog>' \ ' <title>Message</title>' \ ' <style></style>' \ ' <control id="Close"/>' \ ' <position>automatic</position>' \ ' <embedding>always_toplevel</embedding>' \ ' <sizemode>automatic</sizemode>' \ ' <size height="169" width="214"/>' \ ' <content columns="1" rows="1">' \ ' <widget row="0" type="display::text" columnspan="1" column="0" rowspan="1">' \ ' <name>text</name>' \ ' <tooltip></tooltip>' \ ' <text><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">' \ '<html><head><meta name="qrichtext" content="1" /><style type="text/css">' \ 'p, li { white-space: pre-wrap; }' \ '</style></head><body style=" ">' \ '<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Report(s) Exported</p></body></html></text>' \ ' <wordwrap>false</wordwrap>' \ ' </widget>' \ ' </content>' \ '</dialog>') Link to comment Share on other sites More sharing options...
[Ma...] Posted July 15, 2022 Author Share Posted July 15, 2022 Hi Keith, Thanks for sharing this. I love the prompt for save location code you have. I tested it out and it works great! I'm adding it to my scripts. Is that html code that defines the dialog box? Link to comment Share on other sites More sharing options...
[Ke...] Posted July 18, 2022 Share Posted July 18, 2022 Hi Mark, It looks like HTML to me, but it comes from rtclick inserting a dialog box. There's probably a better way but one day i may have time! Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in