API 예: 압력 데이터 읽기

API를 통해 시간 계열 데이터를 플롯의 독립적인 값으로 사용할 수 있습니다. 이는 애니메이션이 표시되는 방법을 나타냅니다.

이 예에서는 다음 작업을 수행합니다.

이 예는 특정 결과 세트를 읽고 싶거나 데이터를 새 결과 세트에 입력하고 싶을 때 사용할 수 있습니다.

'%RunPerInstance
'@
'@ DESCRIPTION
'@ Split Presssure Time Series Result into Individual Results.
'@ Recreate the Pressure Time Series Result
'@
'@ SYNTAX
'@ ReadingPressureData
'@
'@ PARAMETERS
'@ none 
'@
'@ DEPENDENCIES/LIMITATIONS
'@ none
'@
'@ History
'@ Created DRA 9/8/2006
'@@ 
Option Explicit
SetLocale("en-us")
Dim SynergyGetter, Synergy
On Error Resume Next
Set SynergyGetter = GetObject(CreateObject("WScript.Shell").ExpandEnvironmentStrings("%SAInstance%"))
On Error GoTo 0
If (Not IsEmpty(SynergyGetter)) Then
  Set Synergy = SynergyGetter.GetSASynergy
Else
  Set Synergy = CreateObject("synergy.Synergy")
End If
Synergy.SetUnits "METRIC"

Dim PlotManager
Dim ResultID, Header, UserPlot, Indp, nodeID, Value, IndpValues, i, j ,Ave, Count, Str

ResultID = 1180

' Split Presssure Result into Individual Results.
Set PlotManager = Synergy.PlotManager()
Set IndpValues = Synergy.CreateDoubleArray()
PlotManager.GetIndpValues ResultID, IndpValues

' Display to Screen Average Pressure at interval through results
For i = 0 to IndpValues.size()-1 Step 5
        Set PlotManager = Synergy.PlotManager()
        Set Indp = Synergy.CreateDoubleArray()
        Indp.AddDouble(IndpValues.val(i))
        Set nodeID  = Synergy.CreateIntegerArray()
        Set Value = Synergy.CreateDoubleArray()
        PlotManager.GetScalarData ResultID, Indp, nodeID, Value
        Ave = 0.0
        Count = 0.0
        For j = 0 To nodeID.size - 1
                Count = Count +1
                Ave = Ave + Value.val(j)
        Next
        If Count > 0 Then
                Ave = Ave / cdbl(count) 
        End If
    Str = Str + "Time=" & CStr(IndpValues.val(i)) & " Average P =" & Ave &" MPa" & vbCRLF
Next
MsgBox Str

'Recreate current Time Series Pressure Result
Set UserPlot = PlotManager.CreateUserPlot()
Header = "New Pressure Time Series"
PlotManager.DeletePlotByName(Header)
UserPlot.SetName(Header)
UserPlot.SetDataType("NDDT")
UserPlot.SetDeptUnitName("MPa")
UserPlot.SetDeptName("Time")
UserPlot.SetVectorAsDisplacement(False)
For i = 0 to IndpValues.size-1
  Set Indp = Synergy.CreateDoubleArray()
  Indp.AddDouble(IndpValues.Val(i))
  Set nodeID  = Synergy.CreateIntegerArray()
  Set Value = Synergy.CreateDoubleArray()
  PlotManager.GetScalarData ResultID, Indp, nodeID, Value
  UserPlot.AddScalarData IndpValues.Val(i), nodeID, Value
Next
UserPlot.Build()


MsgBox "Script Complete"
Wscript.Quit