How to export saved view using OpenSTAAD functions (VBA)


 

 

       
  Applies To     
       
  Product(s): STAAD.Pro  
  Version(s): All  
  Environment:  N/A  
  Area:  OpenSTAAD  
  Subarea:  View  
  Original Author: Shreyanka Bhattacharjee, Bentley Technical Support Group  
       

 

 

 

 

 

 

 

 

Problem Description:

How to export saved view using OpenSTAAD functions (VBA)

Solution:

 

Along with that, the functions mentioned below can be used to open the view and resize and reposition active window to capture the image.

These functions are available from STAAD.Pro Advanced 2024 - Version 24.00.00.577

Parameter:

The details of the Parameter can be found in OpenSTAAD Documentation under Help option

Sample VBA Syntax:

    Sub Export_View()

        Dim varReturnVal As Long
        Dim nName As String
        Dim windowOptions As Boolean
        Dim count As Long
        Dim xWindow As Long
        Dim yWindow As Long
        Dim vnName(2) As String
        Dim xTop As Long
        Dim yTop As Long
        Set objOpenStaad = GetObject(, "StaadPro.OpenSTAAD")
        
        vnName(0) = "view1"
        vnName(1) = "view2"
        vnName(2) = "view3"
        
        xTop = 0
        yTop = 0
        
        windowOptions = True
        For i = 0 To 2
            
            varReturnVal = objOpenStaad.View.OpenView(vnName(i), windowOptions)
            
            ID = 1
            objOpenStaad.View.SetActiveWindow ID
            
            
            objOpenStaad.View.GetApplicationDesktopSize xWindow, yWindow
            varReturnVal = objOpenStaad.View.SetWindowPosition(xTop, yTop, xWindow, yWindow)
            
            Application.Wait (Now + TimeValue("0:00:01"))
            
            fileLoc = "D:\Export View" 'Change this location as per the requirement
            Filename = "Image" & i + 1
            FileType = 1 '0 = bmp, 1 = jpg, 2 = tga, 3 = tif
            overWrite = True
            objOpenStaad.View.ExportView fileLoc, Filename, FileType, overWrite

        Next i
    End Sub

Output:

Please refer to the article below to save view using openSTAAD

https://bentleysystems.service-now.com/community?id=kb_article_view&sys_kb_id=1224adc197845e1036d5f33ef053aff7