ApplicationExit and ApplicationStart

ApplicationStart

ApplicationStart

Syntax

SapObject.ApplicationStart

VB6 Procedure

Function ApplicationStart(Optional ByVal Units As eUnits = kip_in_F, Optional ByVal Visible As Boolean = True, Optional ByVal FileName As String = “”) As Long

Parameters

Units

The database units used when a new model is created. Data is internally stored in the program in the database units. The database units may be one of the following items in the eUnits enumeration:

lb_in_F = 1

lb_ft_F = 2

kip_in_F = 3

kip_ft_F = 4

kN_mm_C = 5

kN_m_C = 6

kgf_mm_C = 7

kgf_m_C = 8

N_mm_C = 9

N_m_C = 10

Ton_mm_C = 11

Ton_m_C = 12

kN_cm_C = 13

kgf_cm_C = 14

N_cm_C = 15

Ton_cm_C = 16

Visible

If this item is True then the application is visible when started.  If it is False then the application is hidden when started.

FileName

The full path of a model file to be opened when the Sap2000 application is started. If no file name is specified, the application starts without loading an existing model.

Remarks

This function starts the Sap2000 application.

When the model is not visible it does not appear on screen and it does not appear in the Windows task bar. 

If no filename is specified, you can later open a model or create a model through the API.

The file name must have an .sdb, .$2k, .s2k, .xls, or .mdb extension. Files with .sdb extensions are opened as standard SAP2000 files. Files with .$2k and .s2k extensions are imported as text files. Files with .xls extensions are imported as Microsoft Excel files. Files with .mdb extensions are imported as Microsoft Access files.

This function returns zero if the application successfully starts and nonzero if it fails.

VBA Example

Sub StartExample()
   ‘dimension variables
      Dim SapObject as cOAPI

      Dim ret as Long

   ‘create Sap2000 object
      Set SapObject = CreateObject(“CSI.SAP2000.API.SapObject”)

   ‘start Sap2000 application
      ret = SapObject.ApplicationStart

   ‘close Sap2000
      SapObject.ApplicationExit False
      Set SapObject = Nothing
End Sub

ApplicationExit

ApplicationExit

Syntax

SapObject.ApplicationExit

VB6 Procedure

Function ApplicationExit(ByVal FileSave As Boolean) As Long

Parameters

FileSave

If this item is True the existing model file is saved prior to closing Sap2000.

Remarks

If the model file is saved then it is saved with its current name. You should set the Sap2000 object variable to nothing after calling this function.

This function returns zero if the function succeeds and nonzero if it fails.

VBA Example

Sub ExitExample()
   ‘dimension variables
      Dim SapObject as cOAPI
      Dim SapModel As cSapModel
      Dim ret as Long

   ‘create Sap2000 object
      Set SapObject = CreateObject(“CSI.SAP2000.API.SapObject”)

   ‘start Sap2000 application
      SapObject.ApplicationStart

   ‘create SapModel object
      Set SapModel = SapObject.SapModel

   ‘initialize model
      ret = SapModel.InitializeNewModel(kip_ft_F)

   ‘create a 3D frame model from template
      ret = SapModel.File.New3DFrame(BeamSlab, 3, 12, 3, 28, 2, 36)   

   ‘close Sap2000
      SapObject.ApplicationExit False
      Set SapModel = Nothing
      Set SapObject = Nothing
End Sub

This entry was posted in SAP2000 API. Bookmark the permalink.