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

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 STAAD.Pro Case 2: Obtaining Output

OpenSTAAD Fundamentals - July 2012

TRN020150-1/0001-PW02

Initiate OpenSTAAD
Create a New Macro and Initiate OpenSTAAD.

1. Open OpenSTAADDataset.std in STAAD.


2. Click on the Run VB Macro icon in the File toolbar.

DO NOT DISTRIBUTE - Printing for Student use is Permitted

3. Click on the Create New button in the Macro dialog.


4. Navigate to the dataset that was supplied with this training and then enter the following parameters in the Select New Macro File Name
dialog:

File Name: Training_Nodal Deflections

Save as Type: Macro Files (*.vbs)

Description of the Macro: Maximum Nodal Displacements

Click on the New button.

5. Enter the following function to initiate OpenSTAAD:


Sub Main()
DESCRIPTION:Maximum Nodal Displacement
Set objSTAADGUI = GetObject (,STAADPro.OpenSTAAD)
End Sub

6. Right-click in the Macro Design Window and select Edit > References from the pop-up menu.
7. Check the STAADLibBentley (1.0) reference in the References dialog. Then, click OK.
8. Keep this model open for the next exercise.

Copyright 2012 Bentley Systems, Incorporated

Get the Primary Load Case Information


Learn to obtain the primary load case information from the STAAD.Pro main application.

1. Continue with the model from the previous exercise.

DO NOT DISTRIBUTE - Printing for Student use is Permitted

2. Enter the following functions to define the primary load case variables:
Dim i As Integer
Dim LCaseCount As Integer
Dim LCaseNum() As Long
Dim LCaseName() As String

3. Enter the following functions to retrieve the Primary Load Case Information from the active STAAD.Pro model:
LCaseCount = objSTAADGUI.Load.GetPrimaryLoadCaseCount()
ReDim LCaseNum(LCaseCount)
ReDim LCaseName(LCaseCount)
objSTAADGUI.Load.GetPrimaryLoadCaseNumbers LCaseNum
For i = 0 To LCaseCount-1
LCaseName(i) = CStr(LCaseNum(i)) & : & objSTAADGUI.Load.GetLoadCaseTitle(LCaseNum(i))
Next i

4. Keep this model open for the next exercise.

Create the Select Load Case Dialog


Learn to create a dialog to be used in the STAAD.Pro main application to select the applicable load case.

1. Continue with the model from the previous exercise.

DO NOT DISTRIBUTE - Printing for Student use is Permitted

Note: In this exercise, we will create the following user dialog to select a defined load case:

2. Click on the Edit User Dialog icon.


3. Double-click anywhere within the new dialog in the UserDialog Editor.
4. Enter the following information into the Edit UserDialog Properties dialog:

Caption: Select Load Case

Then, click on the double right arrow button to enter the name of the dialog box.

5. Click on the Add Text icon in the UserDialog Editor. Click within the new dialog to define the text box location and then double-click within
the new text box.

6. Enter the following information into the Edit Text Properties dialog:

Caption: Load Case:

Quoted: (checked)

Click on the double right arrow button to enter the name of the field. Then, click Close.

Copyright 2012 Bentley Systems, Incorporated

7. Click on the Add List Box icon in the UserDialog Editor. Click within the new dialog to define the list box location and then double-click
within the new list box.

8. Enter the following information into the Edit List Box Properties dialog:

Array: LCaseName

DO NOT DISTRIBUTE - Printing for Student use is Permitted

Click on the double right arrow button to enter the name of the field. Then, click Close.

9. Click on the Add OK Button icon in the New UserDialog Editor. Then, click within the new dialog to define the OK button.
10. Click on the Add Cancel Button icon in the New UserDialog Editor. Then, click within the new dialog to define the Cancel button.
11. Click on the Save and Edit icon in the New UserDialog Editor.
12. Delete the last line of this code (Dialog dlg).
13. Keep this model open for the next exercise.

Copyright 2012 Bentley Systems, Incorporated

Obtain the Selected Load Case Results


Learn to define the variables that were used in the Select Load Case dialog.

1. Continue with the model from the previous exercise.

DO NOT DISTRIBUTE - Printing for Student use is Permitted

2. Enter the following functions to define the input variables:


Dim dlgResult As Integer
dlgResult = Dialog(dlg)
If dlgResult = -1 Then
Dim LoadCase As Long
Dim LoadCaseName As String
LoadCase = LCaseNum(dlg.ListBox1)
LoadCaseName = LCaseName(dlg.ListBox1)

3. Enter the following functions to instruct STAAD.Pro to cancel the operation of the Cancel button was clicked:
ElseIf dlgResult = 0 Then
Debug.Print Cancel button Pressed
End If

4. Keep this model open for the next exercise.

Copyright 2012 Bentley Systems, Incorporated

Get the Selected Node Information


Learn to obtain the selected node information from the STAAD.Pro main application.

1. Continue with the model from the previous exercise.

DO NOT DISTRIBUTE - Printing for Student use is Permitted

2. Enter the following functions to determine if any nodes have been selected in the main application:
Dim NumSelNodes As Long
Dim SelNodeArray() As Long
NumSelNodes = objSTAADGUI.Geometry.GetNoOfSelectedNodes()
If NumSelNodes > 0 Then
ReDim SelNodeArray(NumSelNodes)
objSTAADGUI.Geometry.GetSelectedNodes(SelNodeArray, 1)
Else
MsgBox Please Select Nodes, vbOKOnly
Exit Sub
End If

3. Enter the following functions to get the nodal displacements for the selected nodes:
Dim j As Integer
Dim NodeNo As Long
Dim DisplArray(6) As Double
Dim MaxDisplArray(6) As Double
Dim NodeArray(6) As String
For i = 0 To NumSelNodes-1
NodeNo = SelNodeArray(i)
objSTAADGUI.Output.GetNodeDisplacements(NodeNo, LoadCase, DisplArray())
For j = 0 To 5
If Abs(DisplArray(j)) > Abs(MaxDisplArray(j)) Then
MaxDisplArray(j) = Round(DisplArray(j), 3)
NodeArray(j) = N & CStr(NodeNo)
End If
Next j
Next i

4. Keep this model open for the next exercise.


Copyright 2012 Bentley Systems, Incorporated

Retrieve the Base Units Configuration


Learn to retrieve the base units configuration that has been specified in the main application.

1. Continue with the model from the previous exercise.

DO NOT DISTRIBUTE - Printing for Student use is Permitted

2. Enter the following functions to determine the base units configuration that were specified in the STAAD.Pro Start Page.
Dim BaseUnit As Integer
BaseUnit = objSTAADGUI.GetBaseUnit
If BaseUnit = 1 Then
BaseLengthUnit = in
Else
BaseLengthUnit = m
End If

3. Keep this model open for the next exercise.

Copyright 2012 Bentley Systems, Incorporated

Return the Maximum Deflection Results


Learn to obtain the maximum deflection results for the selected nodes and the selected load case.

1. Continue with the model from the previous exercise.

DO NOT DISTRIBUTE - Printing for Student use is Permitted

Note: In this exercise, we will create the following user dialog to display the maximum deflection of the selected nodes:

2. Click on the Edit User Dialog icon.


3. Double-click anywhere within the new dialog in the UserDialog Editor.
4. Enter the following information into the Edit UserDialog Properties dialog:

Caption: Maximum Deflection

Then, click on the double right arrow button to enter the name of the dialog box.

5. Use the Add Text tool to add the following text fields to the dialog:

Load Case:

X:

Y:

Z:
Note: Ensure that the Quoted field is selected when defining the text fields.

Copyright 2012 Bentley Systems, Incorporated

DO NOT DISTRIBUTE - Printing for Student use is Permitted

6. Use the Add Text tool to add the following text fields to the dialog:

LoadCaseName

CStr(MaxDisplArray(0))

CStr(MaxDisplArray(1))

CStr(MaxDisplArray(2))

BaseLengthUnit

NodeArray(0)

NodeArray(1)

NodeArray(2)
Note: Ensure that the Quoted field is not selected and the Field parameter is left blank when defining the text fields for the variables.

7. Click on the Add OK Button icon in the New UserDialog Editor. Then, click within the new dialog to define the OK button.
8. Click on the Save and Edit icon in the New UserDialog Editor.
9. Redefine the User Dialog by changing the last two lines in the macro to the following:
Dim dlg2 As UserDialog
Dialog dlg2

10. Terminate the Macro:


Set objSTAADGUI = Nothing
End Sub

Copyright 2012 Bentley Systems, Incorporated

10

Add the Nodal Deflections Macro to the Toolbar


Learn to add a macro to the user tools in the toolbar.

1. Continue with the model from the previous exercise.


2. Click Tools > Configure User Tools... in the menu bar.

DO NOT DISTRIBUTE - Printing for Student use is Permitted

3. Click on the New (Insert) icon in the Customize User Defined Tools dialog.
4. Enter the name Training_Nodal Deflection into the Menu Items window.
5. Click on the ... button adjacent to the Command string in the Customize User Defined Tools dialog.
6. Navigate to the Training_Nodal Deflections.vbs file you just created in the Select File dialog. Then, click Open.
7. Click OK in the Customize User Defined Tools dialog.
8. Keep this model open for the next exercise.

Copyright 2012 Bentley Systems, Incorporated

11

Analyze the Model and Run the Macro


Learn to analyze the model in the main application and run the macro.

1. Continue with the model from the previous exercise.


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

DO NOT DISTRIBUTE - Printing for Student use is Permitted

3. Select the Stay in Modeling Mode radio button in the STAAD Analysis and Design dialog. Then, click Done.
4. Click Select > By All > All Nodes in the menu bar.

5. Click on the User Tools icon in the File toolbar. Then, select Training_Node Displacements from the pull down menu.
6. Highlight the Wind Load case in the Select Load Case dialog. Then, click OK.
Note: Notice that the Maximum Deflection dialog has now returned the maximum translational deflection in the X, Y, and Z axis global
directions and the corresponding node number.

7. Click OK in the Maximum Deflection dialog.


Copyright 2012 Bentley Systems, Incorporated

12

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