Вы находитесь на странице: 1из 2

Here is a starting guide to using OpenSTAAD in STAAD.Pro - OpenSTA...

1 of 2

http://communities.bentley.com/communities/other_communities/openstaad...

OpenSTAAD
This is where you can find and contribute to discussions, ideas, and other
information about OpenSTAAD.

Here is a starting guide to using


OpenSTAAD in STAAD.Pro
Carlos Aguera Thu, Jun 30 2011 2:16 PM

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)
2)
3)
4)

5)

In STAAD.Pro click on the menu item Edit>Create New VB Macro


Provide a suitable name and loca&on to store the VBS le that will contain your macro
The macro will give you the basic frame work which will be a subrou&ne called Main() which will be where the
macro will start.
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 func&ons in the Object
Browser.
Create your OpenSTAAD object(s). The following shows the create a general object that is set to an OpenSTAAD
item, however as it is dened as an OBJECT the available func&ons/methods are not displayed when the period
bu:on is clicked:Dim objSTD As Object
Set objSTD = GetObject(,"StaadPro.OpenSTAAD")
6) Alterna&vely dene as the OpenSTAADUI has been added to the project (see 4 above), then it is possible to
dene the object directly as an OpenSTAAD object where you can see the available func&ons/subrou&nes by
pressing the period aAer 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 subrou&nes/func&ons.
Which can be accessed thus:oSTD.Geometry.GetNodeCount()

However, whilst the property Geometry is displayed when the period bu:on is clicked aAer oSTD, the list of func&ons in
Geometry is not listed aAer clicking the period bu:on aAer selec&ng Geometry.
8) The alterna&ve to see all the subrou&nes/func&ons 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 prac&ce is to clean up the open objects before leaving e.g. :Set oSTD = Nothing
Set ostdGeometry =Nothing
10) Therefore the basic star&ng point for a macro would be (copy-paste this as your star&ng point):-

7/31/2011 11:25 PM

Here is a starting guide to using OpenSTAAD in STAAD.Pro - OpenSTA...

2 of 2

http://communities.bentley.com/communities/other_communities/openstaad...

Sub Main()
'Create an instance of OpenSTAAD le
Dim oSTD As OpenSTAAD
Set oSTD = GetObject(,"StaadPro.OpenSTAAD")
Create objects to access func&ons 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

7/31/2011 11:25 PM

Вам также может понравиться