Query about openstaad properties function

Hello ppl,

 I am trying to get beam geomerical properties (specifically width and depth) through Openstaad feature (specifically GetBeamProperty) and so far failing.

When i run the corresponding VBA code i get result as either "TRUE" or "1" or not at all. Please check out the VBA code and see what needs to be rectified ?

Any help would be deeply appreciated.

 

Sub bea_len()

 With Sheets("Tabulation")

  Dim objOpenSTAAD As Object

 Dim BeamNo As Long

Dim Width, Depth, Ax, Ay, Az, Ix, Iy, Iz, pro(0 To 7) As Double

'Get the application object --

 Set objOpenSTAAD = GetObject(, "StaadPro.OpenSTAAD")

 BeamNo = 44

     'Get geometrical properties of  Beam

 For i = 0 To 7

  pro(i) = objOpenSTAAD.Property.GetBeamProperty(BeamNo, Width, Depth, Ax, Ay, Az, Ix, Iy, Iz)

  Cells(i + 4, "C").Value = pro(i)

Next i

Set objOpenSTAAD = Nothing

 End With

 End Sub

Parents
  • I am not sure what value you want to extract as pro(i) returns the execution status of the function only, not the property values. Now about your code, all the property values are extracted as 0 as the variable types are mentioned incorrectly. The following line indicates that you have defined pro() array as double, rest of the variables are not defined. 

    Dim Width, Depth, Ax, Ay, Az, Ix, Iy, Iz, pro(0 To 7) As Double

    This should be modified as --

    Dim Width As Double, Depth As Double, Ax As Double, Ay As Double, Az As Double, Ix As Double, Iy As Double, Iz As Double, pro(0 To 7) As Double

    Also I am not sure why you introduce a loop with same beam number. I have tested the following macro which works fine --

    Dim BeamNo As Long
    Dim Width As Double, Depth As Double, Ax As Double, Ay As Double, Az As Double, Ix As Double, Iy As Double, Iz As Double
    Dim p As Long
    Set objOpenSTAAD = GetObject(, "StaadPro.OpenSTAAD")
    BeamNo = 1
    p = objOpenSTAAD.Property.GetBeamProperty(BeamNo, Width, Depth, Ax, Ay, Az, Ix, Iy, Iz)



Reply
  • I am not sure what value you want to extract as pro(i) returns the execution status of the function only, not the property values. Now about your code, all the property values are extracted as 0 as the variable types are mentioned incorrectly. The following line indicates that you have defined pro() array as double, rest of the variables are not defined. 

    Dim Width, Depth, Ax, Ay, Az, Ix, Iy, Iz, pro(0 To 7) As Double

    This should be modified as --

    Dim Width As Double, Depth As Double, Ax As Double, Ay As Double, Az As Double, Ix As Double, Iy As Double, Iz As Double, pro(0 To 7) As Double

    Also I am not sure why you introduce a loop with same beam number. I have tested the following macro which works fine --

    Dim BeamNo As Long
    Dim Width As Double, Depth As Double, Ax As Double, Ay As Double, Az As Double, Ix As Double, Iy As Double, Iz As Double
    Dim p As Long
    Set objOpenSTAAD = GetObject(, "StaadPro.OpenSTAAD")
    BeamNo = 1
    p = objOpenSTAAD.Property.GetBeamProperty(BeamNo, Width, Depth, Ax, Ay, Az, Ix, Iy, Iz)



Children
No Data