Utilizing the SYS input in SOFiSTiK FEA

calendar_16x16 17 Feb 2024 • Posted by user_16x16 Smiljan Tukić

Video

By loading the video, you accept YouTube's privacy policy.

Learn more

Video URL: https://youtu.be/XlZWNpJR2Pk

Introduction

By following the instructions in this blog article, you will gain insights into utilizing the SYS input to optimize and automate your SOFiSTiK workflow. This functionality allows you to execute various scripts or executables seamlessly within the SOFiSTiK Calculation program. The calculation process intelligently pauses until SYS completes, negating the need for manual intervention.

Example given, see input below:

+PROG SOFIMSHC
HEAD
$...
END

+SYS python <scriptname>.py

+PROG ASE
HEAD
$...
END
  1. The program will invoke the SOFIMSHC module,

  2. Subsequently, the SYS input will be executed, initiating the execution of <scriptname>.py.

  3. Upon successful completion of the SYS input, the ASE module will start its calculations.

If you do not use SYS but need the results from upper module, then you must wait for upper module to complete its calculation before manually running the script and starting the ASE calculation.

Manually initiating each step is not user-friendly and time consuming. SYS eliminates this hassle, enabling you to start your calculation and step away while it proceeds seamlessly from start to finish. This way you can get a coffee, instead of waiting for each part to finish.

Examples

To showcase the application of SYS, we will concentrate on a concise example and use-case.

  1. Get date and time via a script

  2. Call executable with arguments (let’s use Report Browser and automatically convert a PLB file to PDF).

Example 1: Get Date and Time via Script

Download

Consider a scenario where you require the current date and time for a script aimed at printing documentation. SOFiSTiK and CADINP alone do not provide a native solution. To address this requirement, the SYS input tool can be utilized.

hint

While we will demonstrate this using a PowerShell script, alternative solutions may be implemented using other programming languages. Any programming language that can handle text files and write data to them can be used to generate a text input, as DAT files are essentially text files.

Subsequently, we’ll create a PowerShell script datetime.ps1 to capture the current date and time, simultaneously generating a new input file (DAT) to pass the data within a #STO variable.

$datum = Get-Date

$datetime = @"
+PROG TEMPLATE
HEAD
STO#DateTime "{0}"
STO#Date "{1}"
STO#Time "{2}"
END
"@ -f $datum.ToString("dd.MM.yyyy hh:mm"),
      $datum.ToString("dd.MM.yyyy"),
      $datum.ToString("hh:mm")

$datetime | Out-File -FilePath "$PSScriptRoot\temp.dat"

By using SYS input you can call a Powershell script.

+SYS powershell " & .\datetime.ps1"

The created temp.dat file will be called by using +APPLY and executed.

$ Get current time and date
+SYS powershell "& .\datetime.ps1"
+APPLY "temp.dat"

$ Test: Call a variable
+PROG TEMPLATE
HEAD TEST
! Now we can call anywhere in CADINP the date and time via the created variables.

<TEXT>
Date and time: #DateTime
Only date: #Date
Only time: #Time
</TEXT>
END

Troubleshoting

If you are unable to execute the script, verify the PowerShell execution policy. It may be restrictive and prevent the execution of external scripts.

On Windows OS, click with right mouse button RMB on the powershell file and select “Properties”. Then click on “Unblock” and confirm by clicking on OK or Apply.

Or try following:

+SYS powershell -ExecutionPolicy bypass "& .\datetime.ps1"

Example 2: Call Executable with Arguments

To automate the conversion of PLB files to PDF after calculations we will use Report Browser which offers a batch functionality that can be controlled via arguments. This eliminates the need for manual intervention and ensures seamless conversion. So we will use this use-case for demonstrating purpose where we will call ursula.exe (Report Browser) and pass the required arguments via SYS.

+SYS powershell -Command (ursula '.\<filename>.plb' -printto:"pdf" -page:all)

where:

  • ursula is the executable

  • <filename>.plb is the PLB name (use relative or absolute path)

  • -printto:"pdf" is an argument that tells Report Browser to use the PDF printer.

  • -page:all is an argument that ursula (Report Browser) supports. It means, print all pages.

hint

Please refer to the official SOFiSTiK FEA documentation, there you will find a list of all available arguments.

Simply include this command at the end of your text input to automatically convert the generated output (PLB files) to PDF format.

$ ...

+PROG TEMPLATE
END
TXB Print some dummy text
END

+SYS powershell -Command (ursula '.\<filename>.plb' -printto:"pdf" -page:all)

What we have done with ursula.exe (Report Browser) can be done with any executable.

Tags: SOFiSTiK SYS CADINP Automatization