Sunteți pe pagina 1din 9

February 22, 2008 [VB MACRO USING OPENSTAAD]

VB Macros in STAAD.Pro using OpenSTAAD


Contents
VB Macros in STAAD.Pro using OpenSTAAD ................................................................ 1 Introduction ..................................................................................................................... 1 What is the difference between an OpenSTAAD Results Object and an OpenSTAAD Application object? ......................................................................................................... 1 How To Create a new VB Macro ................................................................................... 2 How To edit a predefined VB Macro ............................................................................. 2 To add a shortcut button on the toolbar .......................................................................... 3 What functions are available with the OpenSTAAD objects?........................................ 5 Example of a Using a VB Macro with an OpenSTAAD Application Object in STAAD.Pro ..................................................................................................................... 7 Structure Wizard ............................................................................................................. 8

Introduction
OpenSTAAD is the name for a set of functions that have been produced to allow users of STAAD.Pro to obtain results from a STAAD analysis (using the OpenSTAAD Results Object) or create STAAD.Pro model data (using the OpenSTAAD Application Object). This document describes how the objects can be created and used

What is the difference between an OpenSTAAD Results Object and an OpenSTAAD Application object?
STAAD.Pro supports two types of OpenSTAAD object. 1) Results Object. This is used to obtain data from a specific STAAD file from inside another application such as Excel. Data such as the forces or displacements can be obtained so that it can be used in the Excel calculations. An OpenSTAAD Results object is created with the command:Set (objectname) = CreateObject("OpenSTAAD.Output.1") This will need to be followed by a command to point to the STAAD.Pro data file from which the results are to be extracted:(objectname).SelectSTAADFile "STAAD filename and path" 2) Application Object. This is used to work with a specific working instance of STAAD.Pro and can be used to both read data and also create STAAD.Pro data. An OpenSTAAD application object is created with the command:Set (objectname) = GetObject(,"StaadPro.OpenSTAAD")

Page1

February 22, 2008 [VB MACRO USING OPENSTAAD]

How To Create a new VB Macro


From the Edit menu, select, Create New VB Macro This opens a dialog box to define the name and location to store the file. Chose a folder location, enter a name and click on the New button.

This will start the file ready for the Macro to be written:-

The code should be written and saved.

How To edit a predefined VB Macro


From the Edit menu, select, Edit Existing VB Macro

Page2

February 22, 2008 [VB MACRO USING OPENSTAAD] This opens a dialog box which should be used to navigate to the required VB Macro and it is opened by double clicking on it or selecting it and clicking on the Open Button.

To add a shortcut button on the toolbar


The File toolbar has an icon called User Tools that can have items added:-

This is configured from the menu item, Tools>Configure User Tools. This opens a dialog box thus:-

Begin by clicking on the New (Inset) button, Enter a description that will appear in the User Tools menu and toolbar button.

Page3

February 22, 2008 [VB MACRO USING OPENSTAAD] Then either type in a full path to the VBS file or click on the button at the end of the Command line and navigate to the file and click Open to enter the data onto the Command line, thus:-

This will add the shortcut on the Tools menu, in a User Tools sub-menu, thus:-

As well as adding an icon that pops up when clicking on the User Tools toolbar icon, thus:-

Selecting either option will launch the VB macro, Sample.VBS in this example.

Page4

February 22, 2008 [VB MACRO USING OPENSTAAD]

What functions are available with the OpenSTAAD objects?


The list of functions can be shown in the Object Browser icon:- , but first the Reference needs to be added. This is done by right clicking to the right of the menu bar and selecting the option, Edit>References:-

Each object has the list of available functions listed in these separate files:1) Results Objects, OpenSTAAD 1.0 Type Library (1.0) 2) Application Objects, OpenSTAADUI(1.0) To view the functions, then click on the Browse Object Button and select the Library for which the list of functions are required. 1) Results Objects, OPENSTAADLib (Select the data type output) 2) Application Objects, OpenSTAADUI The list of functions are displayed in the Methods/Properties list. Selecting any of these displays the parameters that are required including the data type.

Page5

February 22, 2008 [VB MACRO USING OPENSTAAD]

Page6

February 22, 2008 [VB MACRO USING OPENSTAAD]

Example of a Using a VB Macro with an OpenSTAAD Application Object in STAAD.Pro


This example shows how the application object can add a beam to a model 10 length units vertically from the last node defined in the model. 1) Create a New Macro file as outlined above 2) Create an instance of an OpenSTAAD application object called oStd(see above) Set oStd = GetObject(,"StaadPro.OpenSTAAD") 3) Check that STAAD.Pro is running by defining a string which will be used to contain the name of the STAAD file and display the name is a messagebox:Dim stdFile as String oStd.GetSTAADFile(stdFile,"TRUE") If stdFile = "" Then MsgBox "This macro can only be run with a valid STAAD file loaded.", vbOkOnly Set oStd = Nothing Exit Sub Else MsgBox stdFile, vbOkOnly End If 4) Get information about the current data in the file Dim pnLastNode as Integer Dim noMemb as Integer Dim dX as Double Dim dY as Double Dim dZ as Double pnLastNode = oStd.Geometry. GetLastNodeNo () noMemb = oStd.Geometry. GetLastBeamNo () oStd.Geometry.GetNodeIncidence pnLastNode, dX, dY, dZ 5) Add a new node 10 length units above the last node in the model oStd.Geometry.CreateNode pnLastNode+1, dX, dY+10, dZ 6) Add the new beam oStd.Geometry.CreateBeam noMemb +1, pnLastNode, pnLastNode+1 7) Close the OpenSTAAD object and end Set oStd = Nothing

Page7

February 22, 2008 [VB MACRO USING OPENSTAAD] End Sub

Structure Wizard
The Structure Wizard has the ability to add models which are defined parametrically using a VB macro such as the two that are included

This is controlled by creating a Structure Wizard Application object Set StwApp = GetObject (,"StWizard.Application") Define the model nodes, beams, plates and solids and then passing the model to STAAD.Pro with the commands:Where Nodes are defined in sequence using an array of X-coordinates (as doubles), an array of Y coordinates (as doubles) and an array of Z coordinates (as doubles). The node number is assigned automatically be the sequence. Beams are defined with a 2 dimensional array. The number of rows is determined by the number of beams and there are three columns starting from column 0. Column 0 is beam number (as an integer). Column 1 is the start node number (as an integer). Column 2 is the end node number (as an integer). Elements as defined in a similar way to beams, but the two dimensional array has 5 columns starting from column 0. The number of rows is determined by the number of elements. Column 0 is element number (as an integer). Column 1 is the node A number (as an integer). Column 2 is the node B number (as an integer). Column 3 is the node C number (as an integer). Column 4 is the node D number (as an integer). For triangular plates, this is a repeat of node C.

Page8

February 22, 2008 [VB MACRO USING OPENSTAAD] Bricks also defined in a 2 dimensional array, but have 9 columns.

'Interface with Structural Wizard StwApp.InterFace.AllocateMemory StwApp.InterFace.SetModelName("name") StwApp.InterFace.SetNoOfNodes(NumOfNodes) StwApp.InterFace.SetNodes NodeX, NodeY, NodeZ StwApp.InterFace.SetNoOfMembers(NumOfMembers) StwApp.InterFace.SetMembers MembData StwApp.InterFace.SetNoOfElements(NumOfElements) StwApp.InterFace.SetElements ElementData StwApp.InterFace.SetNoOfBricks(NumOfBricks) StwApp.InterFace.SetBricks BrickData StwApp.GenerateUserModel The object should then be cleared up thus:Set StwApp = Nothing

Page9

S-ar putea să vă placă și