Define gridlines in ETABS using Excel VBA

Viewed 18

I want to create an Etabs file and define gridlines using Excel VBA. I can open Etabs and create a blank file with the below code but the SetTableForEditingArray function doesn't work. Can anyone help me?

Sub Main()
  'create API helper object
  Dim myHelper As ETABSv1.cHelper
  Set myHelper = New ETABSv1.Helper

  'dimension the ETABS Object as cOAPI type
  Dim myETABSObject As ETABSv1.cOAPI
  Set myETABSObject = Nothing

  'use ret to check return values of API calls
  Dim ret As Long

  Set myETABSObject = myHelper.CreateObjectProgID("CSI.ETABS.API.ETABSObject")
  'start ETABS application
  myETABSObject.ApplicationStart


  'get a reference to cSapModel to access all API classes and functions
  Dim mySapModel As ETABSv1.cSapModel
  Set mySapModel = myETABSObject.SapModel

  'initialize model
  ret = mySapModel.InitializeNewModel(eUnits_kN_m_C)

  'create a blank model
  ret = mySapModel.File.NewBlank()
  Dim TableKey As String
  TableKey = "Grid Definitions - Grid Lines"
  Dim TableVersion As Long
  TableVersion = 0
  Dim FieldsKeysIncluded() As String
  Dim Data() As String
  FieldsKeysIncluded = Split("Name,Grid Line Type,ID,Ordinate,Angle,X1,Y1,X2,Y2,Bubble Location,Visible", ",")
  Data = Split("G1,X (Cartesian),B,10,,,,,,End,Yes", ",")

  ret = mySapModel.DatabaseTables.SetTableForEditingArray(TableKey, TableVersion, FieldsKeysIncluded, NumberRecords, Data)
 
  ret = mySapModel.DatabaseTables.ApplyEditedTables(True, 0, 0, 0, 0, "")

  'clean up variables
  Set mySapModel = Nothing
  Set myETABSObject = Nothing

End Sub
0 Answers
Related