.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/00-basic/06-create-report-templates.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_00-basic_06-create-report-templates.py: .. _ref_create_report_templates: Creating report templates ========================= Templates are used to specify how the final report will be organised. They can be nested to describe the layout of subsections in greater detail. .. note:: This example assumes that you have a local Ansys installation. Initially, create and start a session as per other examples. .. GENERATED FROM PYTHON SOURCE LINES 18-26 Start an Ansys Dynamic Reporting service ---------------------------------------- Start an Ansys Dynamic Reporting service on a new database. The path for the database directory must be to an empty directory. Get the serverobj property from the service. This property will be used to create the template. .. GENERATED FROM PYTHON SOURCE LINES 26-36 .. code-block:: Python import ansys.dynamicreporting.core as adr db_dir = "C:\\tmp\\my_local_db_directory" ansys_ins = "C:\\Program Files\\Ansys Inc\\v241" adr_service = adr.Service(ansys_installation=ansys_ins, db_directory=db_dir) session_guid = adr_service.start(create_db=True) server = adr_service.serverobj .. GENERATED FROM PYTHON SOURCE LINES 37-43 Create a template ~~~~~~~~~~~~~~~~~~ The template is a plan of how ADR items will be presented in the final report. The contents of sections is specified by filters that query the tags of items in the database. .. GENERATED FROM PYTHON SOURCE LINES 43-49 .. code-block:: Python template_0 = server.create_template(name="My Report", parent=None, report_type="Layout:basic") server.put_objects(template_0) .. GENERATED FROM PYTHON SOURCE LINES 50-58 Nesting templates ~~~~~~~~~~~~~~~~~ Templates can be nested to describe layouts within a section, with the topmost template being the report itself. Filters are composed of strings in a common format. The format is explained in more detail on this page [Query Expressions](https://ansyshelp.ansys.com/public/account/secured?returnurl=/Views/Secured/corp/v251/en/adr_ug/adr_ug_query_expressions.html?q=query%20expression). .. GENERATED FROM PYTHON SOURCE LINES 58-78 .. code-block:: Python template_1 = server.create_template(name="Intro", parent=template_0, report_type="Layout:panel") template_1.set_filter("A|i_type|cont|html,string;") server.put_objects(template_1) server.put_objects(template_0) template_2 = server.create_template(name="Plot", parent=template_0, report_type="Layout:panel") template_2.set_filter("A|i_type|cont|table;") server.put_objects(template_2) server.put_objects(template_0) # Close the service # ----------------- # # Close the Ansys Dynamic Reporting service. The database with the items that # were created remains on disk. # sphinx_gallery_thumbnail_path = '_static/00_create_db_0.png' adr_service.stop() .. _sphx_glr_download_examples_00-basic_06-create-report-templates.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 06-create-report-templates.ipynb <06-create-report-templates.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 06-create-report-templates.py <06-create-report-templates.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 06-create-report-templates.zip <06-create-report-templates.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_