Can I Write Scripts to Automate StressCheck Professional?
“Hands-off” automation of StressCheck® Professional pre-processing, solutions and live dynamic processing is available via StressCheck®‘s COM API. The StressCheck® COM API includes access to the toolkit of StressCheck®‘s objects, methods and properties to allow for solutions to repetitious and/or challenging FEA models and the development of Simulation Applications (Sim Apps).
Below is an example of a fracture mechanics Sim App:
Customized functions and subroutines may be written and executed either via scripting or a distributable Sim App product which uses StressCheck® as its FEA engine. In order to get started with the StressCheck® COM API, the following are required:
- A complete StressCheck® installation.
- If using a concurrent license server, enough available licenses for the StressCheck® modules called during execution of the script (e.g. StressCheck® Core, Linear Elasticity solver, etc.).
- A scripting platform (e.g. MATLAB by MathWorks, Microsoft Excel VBA, Python, etc.) or Windows development environment (e.g. Microsoft Visual Studio).
- Referencing/importing/using the StressCheck® COM API (more below).
Scripting with StressCheck®‘s COM API
The following demonstrates in several programming languages (Excel VBA, MATLAB and Python) how to get started with the StressCheck® COM API for scripting. Note: in the below examples, the ® character is not required:
Excel VBA: Set StressCheck® Reference and Initiate a New StressCheck®.Application
In Excel VBA, it is very easy to automate StressCheck® because all that is required is an installation of Microsoft Office Excel. The following video demonstrates how to set a reference to the latest StressCheck® Application Object library in VBA’s References list, and then initiate a new StressCheck® Application via VBA scripting:
More examples of Excel VBA scripting with StressCheck®:
- Helpful Hints and Tips: Excel VBA Basic Example
- Helpful Hints and Tips: Excel VBA 3D Automeshed Plate Example
MATLAB: Launch a StressCheck®.Application COM ActiveX Server
In MATLAB, it is simple enough to create a new ActiveX server StressCheck®.Application process and save the commands as an M-file (.m):
% Launch StressCheck® application as a COM ActiveX Server SC = actxserver(‘StressCheck®.Application’);
For an example of MATLAB scripting with StressCheck®:
Python: Import win32com and use EnsureDispatch to Initiate a StressCheck®.Application
Before using the StressCheck® COM API with Python, it is necessary to install the latest Python for Windows and PyWin32 extensions:
- Python for Windows
- PyWin32 (required for COM API’s)
Once these are installed, you may write a Python script (.py) and execute via command line or Pythonwin. Import win32com in the Python script to open a new StressCheck®.Application:
import win32com.client as win32 sc = win32.gencache.EnsureDispatch(‘StressCheck®.Application’)
For an example of Python scripting with StressCheck®:
For more information on the StressCheck® COM API implementation, refer to COM Interface Overview.