×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

ETABS api VBA code for making changes in existing modal of etabs

ETABS api VBA code for making changes in existing modal of etabs

ETABS api VBA code for making changes in existing modal of etabs

(OP)
Dear all,

I have question that , is there any way i can connect my existing modal of etabs to excel vba through API. I wand to modify load combination , my modal have already combos , i want to replace it with new one

I have found some vba code in ETABS refrence file , but it create a new model and i want to modify an existing model , code is below as:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Sub Example()
Dim SapModel As cSapModel
Dim EtabsObject As cOAPI
Dim ret As Integer = -1
Dim Selected As Boolean

'create ETABS object
EtabsObject = CreateObject("CSI.ETABS.API.ETABSObject")

'start ETABS application
ret = EtabsObject.ApplicationStart()

'create SapModel object
SapModel = EtabsObject.SapModel

'initialize model
ret = SapModel.InitializeNewModel()

'create steel deck template model
ret = SapModel.File.NewSteelDeck(4,12,12,4,4,24,24)

'add combo
ret = SapModel.RespCombo.Add("COMB1", 0)

'add load case to combo
ret = SapModel.RespCombo.SetCaseList("COMB1", eCNameType.LoadCase, "DEAD", 1.4)

'run analysis
System.IO.Directory.CreateDirectory("c:\CSI_API_temp")
ret = SapModel.File.Save("C:\CSI_API_temp\example.edb")
ret = SapModel.Analyze.RunAnalysis

'deselect all cases and combos
ret = SapModel.Results.Setup.DeselectAllCasesAndCombosForOutput

'set combo selected for output
ret = SapModel.Results.Setup.SetComboSelectedForOutput("COMB1")

'check if combo is selected
ret = SapModel.Results.Setup.GetComboSelectedForOutput("COMB1", Selected)

'close ETABS
EtabsObject.ApplicationExit(False)

'clean up variables
SapModel = Nothing
EtabsObject = Nothing
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''

can any suggest me to modify above code for existing model

thanks in advance

RE: ETABS api VBA code for making changes in existing modal of etabs

Instead of these two:
--------------------------------------------------------------------------------
'create ETABS object
EtabsObject = CreateObject("CSI.ETABS.API.ETABSObject")

'start ETABS application
ret = EtabsObject.ApplicationStart()[/indent]
--------------------------------------------------------------------------------

You need the following lines in order to attach to the existing model:
--------------------------------------------------------------------------------
'attach to a running instance of ETABS
'get the active ETABS object
Set EtabsObject = GetObject(, "CSI.ETABS.API.ETABSObject")

'get a reference to cSapModel to access all OAPI classes and functions
Set SapModel = EtabsObject.SapModel
--------------------------------------------------------------------------------

Also, the following lines will create a new instance and use a template, so you need to delete or add a switch to these in order to use your existing model:
--------------------------------------------------------------------------------
'initialize model
ret = SapModel.InitializeNewModel()

'create steel deck template model
ret = SapModel.File.NewSteelDeck(4,12,12,4,4,24,24)
--------------------------------------------------------------------------------

The final result should look like this:
--------------------------------------------------------------------------------
Public Sub Example()
Dim SapModel As cSapModel
Dim EtabsObject As cOAPI
Dim ret As Integer = -1
Dim Selected As Boolean

Set EtabsObject = Nothing
Set EtabsObject = GetObject(, "CSI.ETABS.API.ETABSObject")
Set SapModel = EtabsObject.SapModel

'add combo
ret = SapModel.RespCombo.Add("COMB1", 0)

'add load case to combo
ret = SapModel.RespCombo.SetCaseList("COMB1", eCNameType.LoadCase, "DEAD", 1.4)

'run analysis
System.IO.Directory.CreateDirectory("c:\CSI_API_temp")
ret = SapModel.File.Save("C:\CSI_API_temp\example.edb")
ret = SapModel.Analyze.RunAnalysis

'deselect all cases and combos
ret = SapModel.Results.Setup.DeselectAllCasesAndCombosForOutput

'set combo selected for output
ret = SapModel.Results.Setup.SetComboSelectedForOutput("COMB1")

'check if combo is selected
ret = SapModel.Results.Setup.GetComboSelectedForOutput("COMB1", Selected)

'close ETABS
EtabsObject.ApplicationExit(False)

'clean up variables
SapModel = Nothing
EtabsObject = Nothing
End Sub
--------------------------------------------------------------------------------

Good luck!

RE: ETABS api VBA code for making changes in existing modal of etabs

(OP)
IS THERE A WAY BY WHICH I CAN SELECT MODEL , BY SOME POPUP WINDOW , I DONT WANT TO ATTACHED ACTIVE MODEL , I HAVE SO MANY MODEL , SO I WANT TO ATTACHED A PARTICULAR ONE , IS THIS POSSIBLE

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close