The ‘Beam Moment Iterator using ESA_XML’ is a simple script written in Windows PowerShell which illustrates the use of ESA_XML. By means of an example the script shows how SCIA Engineer can be run iteratively while each time changing the inputs based on the results of the previous iteration step.
![SCIA Seps](/sites/default/files/styles/embed_medium/public/images/2022-05/seps.png?itok=c17TZiHv)
Prerequisites
The project file was saved using SCIA Engineer version 18.0
The PowerShell script was written using PS version 5.1 under Windows 10
Introduction
The ‘Beam Moment Iterator’ is a simple script written in Windows PowerShell which illustrates the use of ESA_XML. By means of an example the script shows how SCIA Engineer can be run iteratively while each time changing the inputs based on the results of the previous iteration step.
PowerShell was used since it has native XML support and is available by default in Windows 10.
The following example is used:
![Beam Moment](/sites/default/files/styles/embed_medium/public/images/2022-01/beammomentiteratorschema.png?itok=onx_Egpe)
A beam on 2 supports is loaded by a line load.
The goal is to set an initial value for the line load and perform a linear calculation, then return the bending moment caused by this line load.
The line load is then modified and the whole process repeated until the bending moment exceeds a given value.
The archive containing the Beam Moment Iterator contains the following files:
- Beam.esa => The project file containing the above use case
- Beam.xml => The XML export of the line load, exported from SCIA Engineer
- Beam.xml.def => The XML export definition of the line load, exported from SCIA Engineer
- XML_Script.ps1 => The PowerShell script
All files should be extracted in the same folder. To see both the script and the output together it’s advised to use the PowerShell ISE.
Description of the Script
Part 1: Inputs
![SCIA beam moment iterator inputs](/sites/default/files/styles/embed_medium/public/images/2022-05/beammomentiteratorinputs.png?itok=m3Qb0Gk-)
The first lines of the script are used to define the inputs: the maximal moment to be reached, the initial value of the lineload and the increment by which the lineload should be increased in each step.
Note that all values are defined in basic SI units for XML (so Nm and N/m). The lineload is set as negative to obtain a positive bending moment in the beam.
In addition to these parameters the path to SCIA Engineer should be defined here since this is needed to run ESA_XML.
In essence this is the only part of the script where changes should be made.
Part 2: Defining files
![SCIA beammoment iterator files](/sites/default/files/styles/embed_medium/public/images/2022-05/beammomentiteratorfiles.png?itok=HBLSmgX_)
This part determines the actual path and assigns the different files to variables.
Part 3: Reading Input XML
![SCIA Beammoment Iterator Reading Xml](/sites/default/files/styles/embed_medium/public/images/2022-05/beammomentiteratorreadingxml.png?itok=j6Hm-2SQ)
The content of the Beam.xml file is read and stored in a variable.
The iteration step is initialized to 1.
Part 4: Modifying the input
![SCIA Beam Moment Iterator Modify Inputs](/sites/default/files/styles/embed_medium/public/images/2022-05/beammomentiteratormodifinputs.png?itok=O6ZgzeAx)
The iteration step starts by storing the defined lineload value into the XML object. This object is then saved as an actual XML file.
Using this ‘temporary’ XML file the original Beam.xml remains unchanged.
Part 5: Running ESA_XML
![SCIA Beam Moment Iterator Running Xml](/sites/default/files/styles/embed_large/public/images/2022-05/beammomentiteratorrunningxml.png?itok=mIui9C9R)
Using ESA_XML the project file is updated with the lineload value and a linear calculation is run.
After this calculation the RESULTS XML I/O document is updated and exported into an XML file.
(For more information on the ESA_XML syntax reference is made to the SCIA Engineer WebHelp)
Part 6: Waiting for- and reading of results
![SCIA Beammoment Iterator Waiting](/sites/default/files/styles/embed_medium/public/images/2022-05/beammomentiteratorwaiting.png?itok=Jzya9on3)
The script needs to wait until the results file appears before continuing.
When the results are available, the content of the XML file is stored in a variable and the bending moment is read from this output.
Part 7: Cleanup and loop
![SCIA Beammoment Iterator Cleanup Loop](/sites/default/files/styles/embed_medium/public/images/2022-05/beammomentiteratorcleanuploop.png?itok=D3sTppYm)
The final part of the iteration cleans up temporary files and prints the output of the given iteration.
The lineload and iteration step get incremented and the bending moment is compared with the maximal value defined at the start.
In case the bending moment of the current iteration is smaller than the maximal value, the iteration continues.
Sample Output
The following provides a sample output of the script when using the default parameters:
![SCIA Beammoment Iterator Output](/sites/default/files/styles/embed_medium/public/images/2022-05/beammomentiteratoroutput.png?itok=O1DykLFU)
The loop ends after 5 steps since the moment of 28125 Nm exceeds the limit of 25000 Nm.
This is not official SCIA software and these community addons are delivered without any warranty or guarantee. So always verify the imported data. If you have any feedback, comments, requests, please feel free to contact us at our e-mail [email protected].
![](/sites/default/files/styles/itr_basic_200/public/icon-downloads2.png?itok=8JnqA2J7)