.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/25-intermediate/00-tagging.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_25-intermediate_00-tagging.py: .. _ref_tagging: Tagging ======= Tagging is an important feature of Ansys Dynamic Reporting. Adding tags to items allows the database to organize them and the templates to create reports in a precise and effective manner. This example shows how to add, modify, query, and delete tags on items. .. note:: This example assumes that you have a local Ansys installation. .. GENERATED FROM PYTHON SOURCE LINES 19-24 Start an Ansys Dynamic Reporting service ---------------------------------------- Start an Ansys Dynamic Reporting service with a new database. The path for the database directory must be to an empty directory. .. GENERATED FROM PYTHON SOURCE LINES 24-32 .. code-block:: Python import ansys.dynamicreporting.core as adr ansys_loc = r"C:\Program Files\ANSYS Inc\v232" db_dir = r"C:\tmp\new_database" adr_service = adr.Service(ansys_installation=ansys_loc, db_directory=db_dir) session_guid = adr_service.start(create_db=True) .. GENERATED FROM PYTHON SOURCE LINES 33-40 Create an item and tag it ------------------------- Now that an Ansys Dynamic Reporting service is running on top of a new database, create an item and set some tags on it. Use the :func:`get_tags` method to see the values of the tags. .. GENERATED FROM PYTHON SOURCE LINES 40-46 .. code-block:: Python my_text = adr_service.create_item() my_text.item_text = "

Analysis Title

This is the first of many items" my_text.set_tags("var=pressure time=0.34") my_text.get_tags() .. GENERATED FROM PYTHON SOURCE LINES 47-53 Modify the tags --------------- Once the tags have been set, you can add or delete to them. Use the :func:`get_tags` method to verify that the new value of the tags is the expected ``var=pressure dp=3``. .. GENERATED FROM PYTHON SOURCE LINES 53-59 .. code-block:: Python my_text.add_tag(tag="dp", value="3") my_text.rem_tag("time") my_text.get_tags() .. GENERATED FROM PYTHON SOURCE LINES 60-67 Query items based on tag values ------------------------------- Add a couple of other items and tag them. Then, query the database for items that have a specific tag set on them. Given the preceding code, this results in only two items. See the contents of the ``dp3_items`` list. .. GENERATED FROM PYTHON SOURCE LINES 67-76 .. code-block:: Python my_second_text = adr_service.create_item() my_second_text.item_text = "

Second Text

Second text item" my_second_text.set_tags("var=temperature dp=3") my_thid_text = adr_service.create_item() my_thid_text.item_text = "

Third Text

An other item" my_thid_text.set_tags("var=temperature dp=2") dp3_items = adr_service.query(filter="A|i_tags|cont|dp=3") .. GENERATED FROM PYTHON SOURCE LINES 77-82 Close the service ----------------- Close the Ansys Dynamic Reporting service. The database with the items that were created remains on disk. .. GENERATED FROM PYTHON SOURCE LINES 82-85 .. code-block:: Python # sphinx_gallery_thumbnail_path = '_static/default_thumb.png' adr_service.stop() .. _sphx_glr_download_examples_25-intermediate_00-tagging.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 00-tagging.ipynb <00-tagging.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 00-tagging.py <00-tagging.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 00-tagging.zip <00-tagging.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_