Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Here is a starting guide to using OpenSTAAD in STAAD.

Pro
Carlos Aguera Thu, Jun 30 2011 2:16 PM Comments 0

So you know about OpenSTAAD, that great, but how to get started with your first macro? Here is some simple guidance on getting the basic framework in place so that you can make use of the functions/subroutines in the OpenSTAAD objects:1) In STAAD.Pro click on the menu item Edit>Create New VB Macro 2) Provide a suitable name and location to store the VBS file that will contain your macro 3) The macro will give you the basic frame work which will be a subroutine called Main() which will be where the macro will start. 4) Add an OpenSTAADUI reference to the project. Right click on the toolbar and select the popup menu Edit>References and select OpenSTAADUI(1.0) . This will allow you to see the available functions in the Object Browser. 5) Create your OpenSTAAD object(s). The following shows the create a general object that is set to an OpenSTAAD item, however as it is defined as an OBJECT the available functions/methods are not displayed when the period button is clicked:Dim objSTD As Object Set objSTD = GetObject(,"StaadPro.OpenSTAAD") 6) Alternatively define as the OpenSTAADUI has been added to the project (see 4 above), then it is possible to define the object directly as an OpenSTAAD object where you can see the available functions/subroutines by pressing the period after the object name:Dim oSTD As OpenSTAAD Set oSTD = GetObject(,"StaadPro.OpenSTAAD") 7) The base OpenSTAAD object includes methods for accessing Geometry, Window, Output etc subroutines/functions. Which can be accessed thus:oSTD.Geometry.GetNodeCount() However, whilst the property Geometry is displayed when the period button is clicked after oSTD, the list of functions in Geometry is not listed after clicking the period button after selecting Geometry. 8) The alternative to see all the subroutines/functions in all these property groups, create separate objects using the base OpenSTAAD object e.g.:'Geometry; Dim ostdGeometry As OpenSTAADUI.OSGeometryUI Set ostdGeometry = oSTD.Geometry 9) Good practice is to clean up the open objects before leaving e.g. :Set oSTD = Nothing

Set ostdGeometry =Nothing 10) Therefore the basic starting point for a macro would be (copy-paste this as your starting point):Sub Main() 'Create an instance of OpenSTAAD file Dim oSTD As OpenSTAAD Set oSTD = GetObject(,"StaadPro.OpenSTAAD") Create objects to access functions in Geometry, Window, etc 'Geometry; Dim ostdGeometry As OpenSTAADUI.OSGeometryUI Set ostdGeometry = oSTD.Geometry 'Window; Dim ostdWindow As OpenSTAADUI.StaadProWindow Set ostdWindow = oSTD.Window 'View; Dim ostdView As OpenSTAADUI.OSViewUI Set ostdView = oSTD.View 'Output; Dim ostdOut As OpenSTAADUI.OSOutputUI Set ostdOut = oSTD.Output 'Property; Dim ostdProperty As OpenSTAADUI.OSPropertyUI Set ostdProperty = oSTD.Property 'Load; Dim ostdLoad As OpenSTAADUI.OSLoadUI Set ostdLoad = oSTD.Load 'Table; Dim oStdTable As OpenSTAADUI.OSTableUI Set oStdTable = oSTD.Table 'Support; Dim oStdSupport As OpenSTAADUI.OSSupportUI Set oStdSupport = oSTD.Support 'Command; Dim oStdCommand As OpenSTAADUI.OSCommandsUI Set oStdCommand = oSTD.Command 'Design; Dim oStdDesign As OpenSTAADUI.OSDesignUI Set oStdDesign = oSTD.Design Write your macro here .. and clear up before closing and leaving the macro

Set oSTD = Nothing Set ostdGeometry = Nothing Set ostdWindow = Nothing Set ostdView = Nothing Set ostdOut = Nothing Set ostdProperty = Nothing Set ostdLoad = Nothing Set oStdTable = Nothing Set oStdSupport = Nothing Set oStdCommand = Nothing Set oStdDesign = Nothing End Sub Good luck Carlos

You might also like