Anda di halaman 1dari 9

Bentley Institute Training

DO NOT DISTRIBUTE - Printing for Student use is Permitted

Practice Workbook
This workbook is designed for use for Live instructor led training and for OnDemand training. The explanation,
demonstration, and narrative content are provided by the instructor in the classroom and in the OnDemand
eLearning version of this course available through Bentley LEARN (learn.bentley.com).
This exercise workbook is formatted for onscreen viewing using a PDF reader.

Using Macros in Excel

OpenSTAAD Fundamentals - July 2012

TRN020150-1/0001-PW03

Analyze the Model in STAAD.Pro


Learn how to open the STAAD.Pro Model and perform an analysis.

1. Open OpenSTAADDataset.std in STAAD.Pro.


Note: In this Practice Workbook, we will perform a concrete beam design in Microsoft Excel using the member properties and the
DO NOT DISTRIBUTE - Printing for Student use is Permitted

maximum bending moments (about the local Z axis) for Beam #21 using the STAAD.Pro model and analysis.
Beam #21

2. Click Analyze > Run Analysis... in the menu bar.


3. Select the Go to Post Processing Mode radio button in the STAAD Analysis and Design dialog. Then, click on the Done button.
4. Click on the Beam tab and then the Graphs sub-tab in the Page Control Area.
5. Use the Beams Cursor to select Beam #21 in the Main Window.
6. Select each of the load combinations through the pull-down menu in the View toolbar. Notice the MZ graph in the Data Area.
Note: The goal of this Practice Workbook is to create a macro in Microsoft Excel to obtain the minimum and maximum moments for a
particular beam for each of the load combinations analyzed. The values of the maximum moment in the Excel file should match
those indicated in the STAAD.Pro analysis results.

7. Keep this model open for the next exercise.

Copyright 2012 Bentley Systems, Incorporated

Initiate OpenSTAAD in Excel


Learn how to initiate OpenSTAAD in MicroSoft Excel and obtain the current STAAD.Pro model.

1. Open Training_Rectangle Beam.xls in MicroSoft Excel.


2. Click on the Developer tab in the Ribbon. Then, click on the Macros icon.

DO NOT DISTRIBUTE - Printing for Student use is Permitted

3. Highlight the RCBeamDesign macro in the Macro dialog. Then, click on the Edit button.
4. Notice that this macro has been called RCBeamDesign using the following code:
Sub RCBeamDesign()

Note: Double click on the Sheet2 (STAAD.Pro Output) item in the VBAProject. Notice that the code to execute the RCBeamDesign macro when
the Get Results button is clicked has already been created. Double click on th Module 1 item in the VBAProject to return to the
RCBeamDesign macro.

5. Enter the following functions in the Macro Design Window to initial the OpenSTAAD object:
Dim objSTAADGUI As Object
Set objSTAADGUI = GetObject (,STAADPro.OpenSTAAD)

6. Enter the following functions to obtain link to the current STAAD.Pro model:
Dim stdFile As String
objSTAADGUI.GetSTAADFile stdFile, True
If stdFile = Then
MsgBox This macro can only be run with a valid STAADfile loaded.,
vbOKOnly
Set objSTAADGUI = Nothing
Exit Sub
End If
Cells(2,2).Value = stdFile

7. Keep this model open for the next exercise.

View the OpenSTAAD Functions


Learn to add the OpenSTAAD Functions to the Object Browser within the Microsoft Excel macro.

1. Continue with the model from the previous exercise.


2. Click on Tools > References in the main menu.

DO NOT DISTRIBUTE - Printing for Student use is Permitted

3. Check the STAADLibBentley option in the References - VBAProject dialog. Then, click OK.
4. Click on the Object Browser icon in the Standard toolbar.
5. Select STAADLibBentley in the pull down menu. Notice that details of each of the OpenSTAAD functions is available now through the
Object Browser in Excel.

6. Close the Object Browser.


7. Keep this model open for the next exercise.

Copyright 2012 Bentley Systems, Incorporated

Establish the Base Units System


Obtain the base unit system from the current STAAD.Pro model.

1. Continue with the model from the previous exercise.

DO NOT DISTRIBUTE - Printing for Student use is Permitted

2. Enter the following functions to establish the Base Units system:


Dim BaseUnit As Integer
Dim BaseLengthUnit As String
Dim BaseForceUnit As String
BaseUnit = objSTAADGUI.GetBaseUnit
If BaseUnit = 1 Then
BaseLengthUnit = in
BaseForceUnit = kips
Else
BaseLengthUnit = m
BaseForceUnit = kN
MsgBox (This macro is designed for English units only. Change the STAAD.Pro > Configuration > Base Unit appropriately.)
Set objSTAADGUI = Nothing
Exit Sub
End If
Cells(4, 6) = BaseLengthUnit
Cells(5, 6) = BaseForceUnit

3. Keep this model open for the next exercise.

Copyright 2012 Bentley Systems, Incorporated

Retrieve the Member Information


Learn to retrieve member information using a member number entered into the Excel spreadsheet.

1. Continue with the model from the previous exercise.


2. Enter the following functions to obtain the member number entered into the Excel worksheet:

DO NOT DISTRIBUTE - Printing for Student use is Permitted

Dim MemberNo As Long


MemberNo = Cells(7,2).value

3. Enter the following functions to verify if the member exists in the STAAD.Pro model:
Dim Length As Double
Length = objSTAADGUI.Geometry.GetBeamLength (MemberNo)
If Length = 0 Then
MsgBox Please check the member number is valid., vbOKOnly
Set objSTAADGUI = Nothing
Exit Sub
End If

4. Enter the following functions to retrieve the member properties from the STAAD.Pro model:
Dim YD As Double
Dim ZD As Double
objSTAADGUI.Property.GetBeamProperty MemberNo, ZD, YD
Cells(7, 7).Value = YD
Cells(8, 7).Value = ZD

5. Keep this model open for the next exercise.

Copyright 2012 Bentley Systems, Incorporated

Retrieve the Loading Information and the Member Forces


Learn to retrieve the loading information and the member force information from the STAAD.Pro model.

1. Continue with the model from the previous exercise.

DO NOT DISTRIBUTE - Printing for Student use is Permitted

2. Enter the following functions to retrieve the number of load combinations defined in the STAAD.Pro model:
Dim LCaseCount As Integer
LCaseCount = objSTAADGUI.Load.GetPrimaryLoadCaseCount
Cells(4, 2).Value = LCaseCount
Dim LComboCount As Integer
LComboCount = objSTAADGUI.Load.GetLoadCombinationCaseCount
Cells(5, 2).Value = LComboCount

3. Enter the following functions to limit the number of load combinations to 10:
If LComboCount > 10 Then
MsgBox (This macro is designed for up to 10 load combinations only.)
Set objSTAADGUI = Nothing
Exit Sub
End If

Note: The Excel spreadsheet was created to consider a maximum of 10 load combinations.
4. Enter the following functions to obtain the load combination titles from the STAAD.Pro model:
Dim LComboNum() As Long
ReDim LComboNum(LComboCount)
Dim LComboTitle() As String
ReDim LComboTitle(LComboCount)
Dim i As Integer
For i = 1 To LComboCount
LComboNum(i) = i + LCaseCount
LComboTitle(i) = objSTAADGUI.Load.GetLoadCaseTitle(i + LCaseCount)
Cells(10, i + 1).Value = LComboNum(i)
Cells(11, i + 1).Value = LComboTitle(i)
Copyright 2012 Bentley Systems, Incorporated

5. Enter the following functions to retrieve the maximum member moment results:
Dim DMax As Double
Dim dMaxPos As Double
Dim DMin As Double
Dim dMinPos As Double
objSTAADGUI.Output.GetMinMaxBendingMoment MemberNo, MZ, LComboNum(i), DMax, dMaxPos, DMin, dMinPos

DO NOT DISTRIBUTE - Printing for Student use is Permitted

Next i

6. Enter the following functions to terminate the macro:


Sheets(Concrete).Select
Set objSTAADGUI = Nothing
End Sub

7. Save and close the Macro Design Window for the next exercise.

Copyright 2012 Bentley Systems, Incorporated

Run the Macro


Learn to run the macro in Microsoft Excel.

1. Continue with the Microsoft Excel worksheet from the previous exercise.
2. Select the STAAD.Pro Output worksheet.

DO NOT DISTRIBUTE - Printing for Student use is Permitted

3. Enter 21 into field B-7 to instruct the macro to obtain the results to beam #21 in the STAAD.Pro model.
4. Click on the Clear Results button to ensure we start with an empty spreadsheet.
5. Click on the Get Results button to run the macro and obtain the results from the STAAD.Pro model.
6. Enter the appropriate parameters for this beam (indicated in the Yellow Fields) to define the following:

Reinforcement Data

Material Data

Strength Reduction Factor

Note: The calculations in the Concrete worksheet have already been defined using the parameters entered for the beam.

Copyright 2012 Bentley Systems, Incorporated