Skip to Main Content
Need Support? Let’s guide you to the right answer or agent.
Status Future consideration
Workspace STAAD.Pro
Created by Guest
Created on Sep 20, 2023

Immediate Steel Take Off

Add function to produce a steel take off immediately without having to run the full analysis.

  • Guest
    Reply
    |
    Sep 26, 2023

    Thanks Carlos. Very helpful. I didn't know about the Table functions.

    1 reply
  • Admin
    Carlos Aguera
    Reply
    |
    Sep 26, 2023

    II agree that there are indeed a number of OpenSTAAD functions that we could look at to make the job a little easier, but I have created an incomplete sample macro which is can be included in STAAD.Pro and creates a STAAD.Pro table which can be copied from using copy and paste, but hopefully illustrates the principles. (Profiles, numbers and overall length are correct, but the total weight is only the volume and needs to be multiplied by the density).


    '/*--------------------------------------------------------------------------------------+'|'|  $Copyright: (c) 2023 Bentley Systems, Incorporated. All rights reserved. $'|'|  Permission To use and distribute this software and its documentation'|  for any purpose, without fee, and without a written agreement,'|  is hereby granted, provided that the above copyright notice,'|  this paragraph and the following two paragraphs appear in all copies,'|  and distributions.'|'|  IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT,'|  INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST'|  PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,'|  EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.'|'|  THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT'|  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A'|  PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF'|  ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". THE AUTHOR HAS NO OBLIGATION'|  To PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, Or MODIFICATIONS.'|'+--------------------------------------------------------------------------------------*/  

    'DESCRIPTION : Sample macro to create a table of envelopes of displacements on node loads

    ' 'Developed By: Carlos Aguera'v1.0 - Sep 2023

    Option Explicit

    Sub Main()
    Dim staadObj As ObjectSet staadObj=GetObject(,"StaadPro.OpenSTAAD")
    Dim stdFile As StringDim nResult As IntegerDim nMembers As LongDim nMember() As LongDim nRows As Integer, nCols As LongDim rptno As Long, tblEnv As Long

    Dim i As LongDim PropTable() As String

    staadObj.GetSTAADFile(stdFile, "TRUE")

    If stdFile<>"" Then
    'Get member data
    nMembers = staadObj.geometry.GetMemberCount()
    ReDim nMember(nMembers)
    staadObj.geometry.GetBeamList(nMember())

    nCols = 4
    nRows = staadObj.property.GetSectionPropertyCount()

    Dim pType As Long, count As Long
    Dim propValues() As Double
    ReDim PropTable(nRows, nCols)

    STAADTable (staadObj, nRows,rptno, tblEnv)

    For i = 1 To nMembers
    nResult = staadObj.property.GetBeamSectionPropertyRefNo (nMember(i-1))

    'No. of objects
    PropTable(nResult,2)= Str(Val(PropTable(nResult,2))+1)

    'Total Length
    PropTable(nResult,3)= Str(Val(PropTable(nResult,3))+staadObj.geometry.GetBeamLength(nMember(i-1)))



    Next

    For i = 1 To nRows
    'Profile name
    nResult = staadObj.property.GetSectionPropertyName(i,PropTable(i,1))

    count = staadObj.Property.GetCountofSectionPropertyValuesEx()
    ReDim propValues(count - 1)
    nResult = staadObj.Property.GetSectionPropertyValuesEx(i,pType,propValues())
    'section area
    PropTable(i,4) = Str(propValues(0)*PropTable(i,3))

    Next


    'Fill table with data
    FillTable(staadObj, nRows, nCols, PropTable(), rptno, tblEnv)

    Else
    MsgBox "This macro can only be run with a valid STAAD file loaded.", vbOkOnlyEnd If

    Set staadObj = NothingEnd Sub

    '********************************************************

    Sub FillTable(staad As Object, nRows As Long,nCols As Long, PropTable() As String, rptno As Long, tblEnv As Long)
    Dim i As Long, j As Long

    For i =1 To nRows
    For j=1 To nCols
    'report, sheet, row, col, data
    staad.table.SetCellValue( rptno, tblEnv, i, j, PropTable(i,j))

    NextNext



    End Sub

    '********************************************************

    Sub STAADTable (staad As Object, NoRows,rptno As Long, tblEnv As Long)
    Dim NoCols As LongDim ColHeader() As StringDim ColUnit() As String
    NoCols =4

    ReDim ColHeader(NoCols)
    ReDim ColUnit(NoCols)
    Dim LenUnit As String, DispUnit As String, RotUnit As String, WeightUnit As String

    'Get unit info
    Select staad.GetBaseUnit
    Case 1
    'BaseUnit = "Base Unit is English"
    LenUnit = "feet"
    DispUnit="in"
    RotUnit="rad"
    WeightUnit="ton"
    Case 2
    'BaseUnit = "Base Unit is Metric"
    LenUnit = "met"
    DispUnit="mm"
    RotUnit="rad"
    WeightUnit= "tonne"
    Case Else
    'BaseUnit = "Base Unit is Undefined"
    End Select

    ColHeader(1)="Profile"
    ColUnit(1)=""
    ColHeader(2)="Number of Objects"
    ColUnit(2)=""
    ColHeader(3)="Total Length"
    ColUnit(3)=LenUnit
    ColHeader(4)="Total Weight"
    ColUnit(4)=WeightUnit


    'Create table
    CreateTable (staad, rptno, tblEnv, NoRows, NoCols, ColHeader(), ColUnit())

    End Sub


    '********************************************************************************************************************************************Sub CreateTable (staad As Object, rptno As Long, tblEnv As Long, Rows As Integer, Cols As Integer, ColHeader() As String,ColUnit() As String )
    Dim i As Integer

    rptno = staad.Table.CreateReport("Take Off")
    'create sheets
    'Table sheet name, number of rows and columns
    tblEnv = staad.Table.AddTable(rptno, "Take Off", Rows, Cols)

    For i = 1 To Cols
    staad.Table.SetColumnHeader rptno, tblEnv, i, ColHeader(i)
    staad.Table.SetColumnUnitString( rptno, tblEnv, i, ColUnit(i))

    Next

    End Sub



  • Guest
    Reply
    |
    Sep 26, 2023

    Yeah, that is an idea so I gave it a try. I had a few issues. When you say "create a table", I can think of a few ways to do that. Yes, I could write a VBA routine in Excel and populate it with the info but I really wanted something I could run within STAAD without having to open Excel. I could also write it to a file then open the file. Still, a little clunky. I could write it to the immediate window but that's not very user friendly. I did try writing it to the MsgBox. It worked but I really want something I can copy and paste if I need to. Then I tried writing it to a textbox in a user form. I liked this except couldn't figure out how to get the program to write the text in instead of the user so I used a text type instead of textbox. That worked but I couldn't copy and paste. I know I could do this in true Visual Basic. I don't know if it's just a limitation of this Visual Basic like program (WinWrap Basic) that comes with STAAD or I need some training.

    The other issue I found is that the only function I found to get the property is "GetMemberDesignSectionName". That seems a bit dangerous as really want the analysis member section name. I couldn't find a function for that. I assume as long as I'm not having the program select member sizes it should be okay, but it would be nice not to have worry about that.

    I'm giving you this rather long winded account for two reasons. One, your reply seems to hint that this has a rather trivial solution. To someone who is not a full-time programmer like me, it's not. The other is to elicit some help from anyone that may know of a good solution to this or just point me to the place that would explain writing text or a table in WinWrap Basic.

  • Admin
    Carlos Aguera
    Reply
    |
    Sep 25, 2023

    Thank you for posting this idea. I would say this would seem ideally suited to an OpenSTAAD macro which creates a table and reports the following

    1) Profile name

    2) Number of objects

    3) Total length

    4) Total Weight

    This would not require any analysis to be performed. Would that not work for you?