<REPORTER FILETYPE='template' VERSION='210' TOTAL_ITEMS='2' TOTAL_PAGES='1' READ_ONLY='true'>

  <SUMMARY TITLE=''>
    <DESCRIPTION></DESCRIPTION>
    <THUMBNAIL AUTO='true'/>
    <![CDATA[png
    000002b3789ceb0cf073e7e592e2626060e0f5f4700902d20780b881830d48c6b6a4650329ce028f
    c8620606be2320cc38559b4f9a818129d5d3c531a462cedb1b67fd8419255a1fe6d7ddcabacdcae9
    c8b3f07bbd6905af8a90b86fc742a7c629657732efac5e5c3c2fdd7cb771b7f9cc9fb3664d489468
    db68ae92316b9964f5e1f797fa6c198e5de9b77de0ffb3a43878f5d555b7d6adbf7e7dfaae7dfbd6
    e997cf5f3d6bddae7deb9f3fafcd359b6d656f2f5fada53c2b87e1f7df7d72e5fc57f5a799d66f5f
    71f96588bffffdacef3f8262af5ffff4778f9fdd8c47be660da74f9f7ef57cb3d4bdbed2ac5dab56
    65dd72addd1171f5eff576a9bee35632f7dce24ede50933e50b475d5d7aabf8f7f56d85c4b0adbba
    f7fed5ab578fefdabd77edcf35d2858aff9b4efe391bfeb78af556def6abdbecff7fbcfebaf46dd9
    6ea9b6e0adb9e1ed87179e3b772e6b674cdfa6aff5664bb52fa4c42d3925f9257f6610c3b9052ec2
    0c17591c4c18057c1946991430df5a77b9f808b56a783e05a642064f573f97754e094d00d317ea6c
    ]]>
  </SUMMARY>
  <SAVE_VARIABLES DIRECTORY='%DEFAULT_DIR%'
                  WRITE='false'
  />

  <EXISTING_FILES OVERWRITE='true' />
  <AUTO_CONFIRM PRIMER='false' />
  <VARIABLE NAME='DEFAULT_DIR'
            TYPE='Directory'
            DESCRIPTION='Reporter default directory'
            VALUE=''
            FORMAT='None'
            PRECISION='2'
            TEMPORARY='false'
  />
  <VARIABLE NAME='DEFAULT_JOB'
            TYPE='File(basename)'
            DESCRIPTION='Reporter default jobname'
            VALUE=''
            FORMAT='None'
            PRECISION='2'
            TEMPORARY='false'
  />
  <VARIABLE NAME='TEST_LSDYNA'
            TYPE='String'
            DESCRIPTION=''
            VALUE=''
            FORMAT='None'
            PRECISION='2'
            TEMPORARY='true'
  />

  <PAGE_SETUP SIZE = 'a4'
              ORIENTATION='portrait'
  />

  <MASTER TITLE='Page master'
        COLOUR='#ffffff'
  >
  </MASTER>
  <PAGE TITLE=''
        COLOUR='#ffffff'
  >
    <ITEM TYPE='script'
          NAME='on_load'
          COORDS='7.0,282.0,17.0,292.0'
          SCRIPT='check_if_WD_exists(Template.GetCurrent().GetVariableValue(&quot;TEST_LSDYNA&quot;));

function check_if_WD_exists(lsdyna_file) {
    let templ = Template.GetCurrent();
    let test_lsdyna = new Variable(templ, &quot;TEST_LSDYNA&quot;, &quot;&quot;, lsdyna_file, &quot;String&quot;, false);
    if (test_lsdyna &amp;&amp; File.Exists(test_lsdyna.value)) {
        generate_item(&quot;Check for Workflow User Data&quot;);
    }
}


/**
 * Finds the first item in the template with the specified &lt;item_name&gt; and generates it.
 * Looks at the master page first, then all the normal pages.
 * @param {string} item_name The name of the item to be generated
 * @param {boolean} [expected = true] If true (default), will exit with an error if the requested item cannot be found
 * @example
 * generate_item(&quot;Check for Workflow User Data&quot;);
 */
function generate_item(item_name, expected = true) {
    let template = Template.GetCurrent();
    /* Loop through all pages in the template, searching for relevant items */
    let pages = template.GetAllPages();
    /* Add Master page to front so we consider it first */
    pages.unshift(template.GetMaster());
    let match = false;
    for (let p = 0; p &lt; pages.length; p++) {
        let items = pages[p].GetAllItems();
        for (let item of items) {
            if (item.name == item_name) {
                LogPrint(`Found item &quot;${item_name}&quot; on page ${p + 1}. Generating...`);
                match = true;
                /* Activate the item before generating it, then return it to its original status */
                let active = item.active;
                item.active = true;
                item.Generate();
                item.active = active;
                break;
            }
        }
        if (match) break;
    }
    if (!match &amp;&amp; expected) {
        LogError(`Could not find item &quot;${item_name}&quot; in order to generate it.`);
        Exit();
    }
}'
          ON_LOAD='true'
          BUTTON='false'
          SKIP_GENERATE='false'
          BUTTON_TEXT=''
    >
    </ITEM>
    <ITEM TYPE='oasys'
          NAME='Check for Workflow User Data'
          COORDS='19.0,282.0,29.0,292.0'
          PROGRAM='T/His'
          FILETYPE='Blank'
          FILE=''
          JOB='%TEST_LSDYNA%'
          OUTLINE='none'
          WIDTH='1'
          IMAGE_SIZE='free'
          OLD_CAPTURE_METHOD='true'
          SCRIPT='let temp_file = `%TEMP_FILE%`;
let workflow_definition_name = `%WF_NAME%`;
check_for_wfud(arguments, temp_file, workflow_definition_name);
WarningMessage(`If T/HIS does not close automatically then &quot;Don&apos;t automatically exit from PRIMER, D3PLOT and T/HIS&quot; is set in REPORTER\nPlease manually close it`);

/**
 * @param {Object} script_args the JavaScript run-time &quot;arguments&quot; object
 * @param {string} temp_file TEMP_FILE to write result
 * @param {string} workflow_definition_name WF_NAME to check for
 */
function check_for_wfud(script_args, temp_file, workflow_definition_name = `Automotive Assessments`) {
    let has_aawd = false;
    let user_data;
    let unit_system;
    let i = 0;
    try {
        if (script_args.length &lt; 2) throw Error(`No workflow data found`);
        if (!script_args[1].selected_models) throw Error(`No selected models`);
        user_data = Workflow.ModelUserDataFromIndex(i, workflow_definition_name);
        unit_system = Workflow.ModelUnitSystemFromIndex(i, workflow_definition_name);
        if (!Object.keys(user_data).length) {
            throw Error(`No user data for model index ${i}`);
        }
        has_aawd = true;
    } catch (error) {}
  
    if (has_aawd) {
        let file = new File(temp_file, File.WRITE);
        let user_data_and_unit_system = {data:user_data, unit_system:unit_system};
        file.Write(JSON.stringify(user_data_and_unit_system));
        file.Close();
    }
}'
    >
    </ITEM>
  </PAGE>
</REPORTER>
