Skip to main content Link Menu Expand (external link) Document Search Copy Copied

filePy Customization

Table of contents

Report Generator can be customized in a number of ways. The files that can be modified by the user are described in the following sections. The files are located in the app installation folder. When an app is installed (WB>Extensions>Install Extension…) it is placed in the user profile and can be located by typing “%appdata%” in the Explorer path and then navigate to the “/Ansys/v231/ACT/extensions/Report Generator V231.1/”.

“/Ansys/v231” <=> Ansys 2023R1).

“Report Generator V231.1” <=> Report Generator for Ansys 2023R1

appdata

extensions

licIcon Maintenance of custom versions

The global version of Report Generator can be updated with the customization files for customer specific versions.

In addition to the Word template and the style preference file reportGeneratorPref.py the automation and customization are defined in the files reportGeneratorDiacritics.py and reportGeneratorCustom.py (Legacy).

When installing a new version of Report Generator starting with version V190.8 the default included customization files can be replaced to change the behavior of the app.

In a multi-user organization the app administrator installs the Report Generator app first and adds the customization files and then shares this app installation according to the instructions on page; “Multi-user deployment of apps - Network” in App and Licence Client Installation instructions.

Make sure to include any new preference options and Word VBA macros defined in the official version described in the following sections.

EDRMedeso can offer the service to create a customer specific version of the app and deliver the customization files to the customer in order to use it in current and future versions. Use “Contact Support” in the “Help” menu for more information or to request a quotation for customization.

filePy reportGeneratorPref.py

The global default report settings are defined in the file “reportGeneratorPref.py” and this file is used when adding the Report Settings object.

Changes made in the Report Settings object can be saved back the the file without the need of manual editing the file itself.

In older versions of the app the settings are described on the page Open Preference.

filePy reportGeneratorDiacritics.py

The language support, fonts, colours, special characters, html tags and custom text identifiers are defined in the file “reportGeneratorDiacritics.py”.

Table Style Settings

Options for table line is defined by the “tableStyleDict” parameter.

TableStyle

Font Style Settings

The available font names and sizes are defined in the “textFontDict” parameter. The fonts are defined with the default language “EN-US”. If a different display language is used then the language in the report is updated to match, e.g. “lang=DE”.

FontStyle

Table Headerline Colour

The available colour names are defined in the “colourMap” parameter. Colours that reverse text colours are defined in the “reverseTextColourList”.

ColourMap

Language settings

The display language of Workbench is used if “languagePath = None”. The selected display language sets text language in the report automatically.

The Workbench language is defined in the “Tools>Options” window:

language

languageGUI

By default the Greek alphabet is enabled (“greekAlphabet = True”). Additional alphabets “Polish” and “Cyrillic” can also be enabled using corresponding lines.

Custom translation can be enabled by setting “languagePath” to something other than Workbench native languages (en-us, de, fr, ja, zh).

The translation of each string must be defined in the corresponding block. Compare with “en-us” etc.

For each new Ansys version new string variables may be added (or removed) from this file. It is therefore recommended to merge in any customization of the file rather than replacing the file!

languageSettings

Diacritics

Regional characters and special symbols are managed by the function “diacritics” that converts the text to corresponding html symbol.

diacritics1

Text identifiers

Conversion of text identifiers for text formatting and Greek letter replacement is managed by the function “textFormatReplace”.

diacritics2

filePy reportGeneratorCustom.py (Legacy)

Starting in V231.4 the “reportGeneratorCustom.py” file is removed and the settings and automation are controlled by the Report Settings object under the “Project Details” and “Report Layout” sections.

The file “reportGeneratorCustom.py” contains model tree functions for the report creation.

insertComments

This function is called when clicking Default Comments and adds the needed comments and can perform Mechanical scripting actions on the model tree.

insertComments

exportReport

This function is called when clicking Create Report.

  • It collects information from the “default comments” and writes project details to the file “reportGenerator.inp” (saved in the Windows temp folder).
  • It calls “writeHTMLreport” to export all information and image to a Html file.
  • It launches the Word template that imports the Html file.

The information written to “reportGenerator.inp” must match the actions in the Word template macro Document_New.

exportReport

writeHTMLreport

This function is called when clicking Html Report and it defines the structure and order of the report. E.g. if “Conclusions” should be written at the end of the report or after the “Introduction”

writeHTMLreport

wordicon ReportGenerator.dotm

The included Microsoft Word template uses VBA macros to execute the import and field conversion actions. When a new document is created the macro Document_New() is called.

The Project Details in the Report Settings object defines the mapping of properties between Mechanical and Word.

The project details and report name is imported from the file “reportGenerator.inp” that is created when “Create Report” is clicked.

One feature is automatic conversion of text to fields. Any text in the report between “{ }” will be treated as a field string.

Macro - Document_New

Macro that is called when a new Word document is created from the Word template.

Document_New

Macro that break existing links to images.

breakLinks

Macro - CallTextToFields

Macro that takes current selection and calls macro “TextToFields”.

CallTextToFields

Macro - TextToFields

Macro that converts a field text to a field object.

TextToFields

Function - GetField

Function that identifies a field text and creates the field object.

GetField

filePy Workbench journaling (Legacy)

  • The report can be automatically exported from a selected analysis system by using Workbench journaling. (The Batch Report feature replaces the need for using journaling.)

  • Identify the System ID (“SYS 2” in this case) and add the lines below to your script (myJournal.wbjn). You may edit the report name using the yellow lines (optional).

  • The journaling script may be used from the project page:

    “File > Scripting > Run Script File…”

  • The journaling script can be added when running Workbench in batch from command prompt:

    “C:\Program Files\ANSYS Inc\V222\Framework\bin\win64\runwb2” –X –R myJournal.wbjn

journaling

Mechanical must be able to open in interactive mode and Word must be installed on the PC if using the batch option.