以字符串形式返回的“值”的单位;

值的计量单位符号可通过 UnitString 属性获得。

使用单位示例

以下子程序利用 UnitString 属性显示闪蒸模块出口压力及其单位。

Sub UnitStringExample(ByVal ihAPSim As Happ.IHapp)
' 本示例获取变量的计量单位符号
Dim ihPresNode As Happ.IHNode
On Error GoTo ErrorHandler
Set ihPresNode = ihAPSim.Tree.Data.Blocks.B3.Output.B_PRES
MsgBox "Flash pressure is: " & ihPresNode.Value & Chr(9) & _
  ihPresNode.UnitString, , "UnitStringExample"
Exit Sub
ErrorHandler:
MsgBox "UnitStringExample raised error " & Err.Description
End Sub

使用Python来解释:

import win32com.client as win32

# 连接 Aspen Plus(版本号按需调整)
ap = win32.Dispatch('AspenPlus.Document.34.0')
ap.InitNew2()                      # 或打开已有文件

# 定位节点:B3 → Output → B_PRES
pres_node = ap.Tree.Data.Blocks.B3.Output.B_PRES

# 取值和单位
value = pres_node.Value
unit  = pres_node.UnitString

# 显示结果
print(f'Flash pressure is: {value}\t{unit}')
# 若喜欢弹窗:
# from tkinter import messagebox
# messagebox.showinfo('UnitStringExample', f'Flash pressure is: {value}\t{unit}')

ap.Quit()