Engineering analysis + design software

User Area > Advice

LPI Scripts: What are they, and how do I start with Visual Basic Scripting for LUSAS?

The LUSAS Programmable Interface (LPI) provides the means of customising LUSAS and of automating a sequence of user specified actions, potentially giving dramatic time savings and increased efficiency.  For example, scripts may be used to automate repetitive modelling and post-processing tasks which will not only save an engineer or analyst time, but also help to ensure consistency and quality.  

The LUSAS Programable Interface (LPI)

The LPI is a powerful tool for customising and automating LUSAS operations. By using VBScript (or any ActiveX compliant scripting language, such as Jscript, Perl, Python, C++, C# etc. ) to access LUSAS facilities and functionality, you can:

  • Create user-defined menu items, dialogs and toolbars
  • Interrogate all aspects of a LUSAS model
  • Customise modelling operations
  • Automate repetitive tasks
  • Import CAD geometry and properties
  • Create parameterised models
  • Make direct links to Word and Excel for import and export of data.
  • Calculate reinforcement quantities
  • Perform simple design checks
  • When used with automated iterative analysis, optimise structural member sizes and configurations

A macro recording facility in LUSAS generates VB scripts for customising. A dialog editor is provided. The use of Visual Basic Runtime means that any VB script can be run in LUSAS.

Note: LUSAS also supports .NET framework. 

Writing scripts

A Visual Basic script file can be written in a text editor such as Notepad and saved with the extension .vbs, this file should then be saved locally.  This command language incorporates variables, loops, conditions, subroutines, arrays and many other high-level programming concepts. 

LUSAS vbs script files should start with $ENGINE=VBScript line and followed by the main script body.

$ENGINE=VBScript
{script body}
{procedures and functions}

VBScript files can be written or recorded:

File > Script > Start Recording...

and then run as and when required by going to:

File > Script > Run Script... 

 There is also a full LPI specific Help for creating VBScripts which can be accessed via:

START > All Programs > LUSAS1x.x > LUSAS Help > LUSAS LPI Help.

You can also access the help through the installation folder:

Lusas1xx\Programs\LPIHelp\index.html 

There are also some example scripts provided with LUSAS that can be found in the folder:

Lusas1xx\Programs\scripts\LPIExamples

Often, one of the easiest ways of establishing how to write a script in VBS is to perform the required actions in Modeller and then look at the session file, filename.ses (after closing or saving the model), or at the recovery file, filename.rcv (whilst the model is open).  These files will contain VBScript for most operations performed in Modeller. 

For more information on writing your own VBScript macros please see the Microsoft Windows Script help documentation.  A copy of this is included on the LUSAS Installation disk in the folder:

Lusas1xx\Third Party\Scripting\VBScripting\VBScript

If you double-click on the "scrdoc56en.exe" file, this will install the help documentation on your PC and will be accessible, by default, through:

START > All Programs > Microsoft Windows Script > Windows Script V5.6 Documentation

Further documentation and run-time libraries for VB scripting can be installed by running the following executables. 

  • Lusas1xx\Third Party\Scripting\VBScripting\vbsdoc.exe

  • Lusas1xx\Third Party\Scripting\VBScripting\vbrun60sp5.exe 

Debugging scripts:

You can debug your script by printing some text messages at different stages in Modeller text window. To see how you can write in Modeller text window see some of the general examples at this page Example Visual Basic Scripts to Download.

In more advanced cases you may use a VBS editor (say VBEdit) to debug your VBS code.

The basic process for running a script through a VBS editor is as follows:

  • Open the script in the VBS editor 

  • Open the LUSAS model in Modeller

  • Ensure that the usual $ENGINE=VBScript command is removed from the top of the script (this can be commented out)

  • Add the command “set modeller = GetObject( , "Lusas.Modeller.1x.x")” to the top of the script, replacing "1x.x" with the appropriate LUSAS version

  • Ensure that all LUSAS commands start with “modeller.” e.g. “GeometryAtts=modeller.db.getAttributes("Geometric","All")” and that the particular . This is required because the editor does not recognise Modeller as a global object.  In the VBS editor set any break points that you wish.

  • Save the script and click the Start button in your VBS editor to run the script

Note that if you later wish to run the script directly through LUSAS modeller again (i.e. using File->Script->Run Script), then it is necessary to do the following:

  • Re-add the command “$ENGINE=VBScript” at the top of the script

  • Change “set modeller = GetObject( , "Lusas.Modeller.1x.x")” to “set modeller =App”

You may notice that scripts run more slowly through VBS editor rather than directly though LUSAS Modeller.

Advanced Customisation:

In advanced customisation of Modeller, VBS commands can also be run as macros stored in a VBScript file or by directly entering single lines of commands straight into the LPI command bar:

View > LPI Command Bar

If a script file of macros has been written, then the code in these files can be loaded through the Advanced button on the LPI Command bar and will be available in any model you create.  These macros are then called via the LPI Command bar.  You can modify this VBScript and add your own VBScript macros by right-clicking on the vbs file and selecting Edit.  

For more information, search for "Command Bar" in Help > Help Topics.

See also

Documentation available


innovative | flexible | trusted

LUSAS is a trademark and trading name of Finite Element Analysis Ltd. Copyright 1982 - 2022. Last modified: January 06, 2023 . Privacy policy. 
Any modelling, design and analysis capabilities described are dependent upon the LUSAS software product, version and option in use.