
2-20 Key HYSYS Objects
2-20
Using GetObject and CreateObject
The SimulationCase object and the Application object can be
created directly through the GetObject function in Visual Basic.
The CreateObject function can also be used to access the
Application object. In general the starting object for most
Automation procedures is the SimulationCase object.
The example below, uses the GetObject function to start-up
HYSYS with the specified case.
The example below, connects to the HYSYS Application object
and enumerates through all the currently open cases. If a case
name matches the specified string then a SimulationCase object
is set to that case. The FOR loop cycles through the list of cases
based on the count value. In Visual Basic arrays and collections
are base 0 unless otherwise specified.
Example 1: Accessing the HYSYS Container Objects
Dim hyCase As SimulationCase
Set hyCase = GetObject(“c:\hysys\cases\c-2.hsc”, “HYSYS.SimulationCase”)
Example 2: Accessing the HYSYS Container Objects
Dim hyApp As HYSYS.Application
Dim hyCases As SimulationCases
Dim hyCase As SimulationCase
Set hyApp = CreateObject(“HYSYS.Application”)
Set hyCases = hyApp.SimulationCases
For j = 0 To hycases.Count - 1
If hycases.Item(j).name = “ethanol.hsc” Then
Set hyCase = hyCases.Item(j)
End If
Next j
Comentários a estes Manuais