1

我在 Aspen HYSYS V9 中构建了一个模拟模板,并希望使用 VBA 自动化将列内部结构的数据(例如内部类型、托盘/填料类型和末端阶段)从 Excel 表传输到 HYSYS。我没有在对象浏览器中找到内部结构,所以我尝试使用后门变量访问内部结构。为了找出这个绰号,我录制了一个脚本,在该脚本中,我打开了一个列的“内部”页面,并将类型从托盘式更改为包装式,然后再改回托盘式。该脚本显示以下内容:

Message "FlowSht.1/UnitOpObject.400(Regenerator)" "view"
Message "FlowSht.1/UnitOpObject.400(Regenerator)/FlowSht.600" "MakeMeActiveColumnOp"
SpecWhileSolving Specify "FlowSht.1/UnitOpObject.400(Regenerator)" ":Enum.590.0"  0.000000000000e+000 
SpecWhileSolving Specify "FlowSht.1/UnitOpObject.400(Regenerator)" ":Enum.590.0"  0.000000000000e+000
SpecWhileSolving Message "FlowSht.1/UnitOpObject.400(Regenerator)/FlowSht.600" "MakeMeActiveColumnOp"
Specify "FlowSht.1/UnitOpObject.400(Regenerator)" ":PageNumber.0"  1.000000000000e+001
SpecWhileSolving Specify "Utility.300(Internals-1@Main Tower@COL4)" ":Index.709"  0.000000000000e+000
Specify "Utility.300(Internals-1@Main Tower@COL4)" ":Index.709"  0.000000000000e+000
SpecWhileSolving Specify "Utility.300(Internals-1@Main Tower@COL4)" ":Selection.711.0"  1.000000000000e+000
Specify "Utility.300(Internals-1@Main Tower@COL4)" ":Index.709"  0.000000000000e+000
Specify "Utility.300(Internals-1@Main Tower@COL4)" ":Index.709"  0.000000000000e+000
SpecWhileSolving Specify "Utility.300(Internals-1@Main Tower@COL4)" ":Selection.711.0"  0.000000000000e+000
Specify "Utility.300(Internals-1@Main Tower@COL4)" ":Index.709"  0.000000000000e+000

然后我写了下面的vba代码:

Dim hyfs As Flowsheet
Dim hyfsBD As BackDoor
Dim hyBDVar As RealVariable

Set hyfs = hycase.Flowsheet
Set hyfsBD = hyfs

Set hyBDVar = hyfsBD.BackDoorVariable("Utility.300(Internals-1@Main Tower@COL1)" & ":Selection.711.0").Variable

hyBDVar.SetValue 1, ""

但 hyBDVar 的返回值为 -32767,我收到一条错误消息:“对象“InternalRealVariable”的“设置值”方法失败。”

4

1 回答 1

0

所以我自己找到了一个解决方案,但它带来了另一个问题。可以通过柱子的子流程访问来指定柱子的内部结构。我使用与上述相同的方法找到了绰号,脚本显示如下:

Message "FlowSht.1/UnitOpObject.400(Absorber)/FlowSht.600/UnitOpObject.400(Main Tower)" "CloseViewX"
Message "FlowSht.1/UnitOpObject.400(Absorber)/FlowSht.600/UnitOpObject.400(Main Tower)" "view"
Specify "FlowSht.1/UnitOpObject.400(Absorber)/FlowSht.600/UnitOpObject.400(Main Tower)" ":Enum.591.1"  0.000000000000e+000
Specify "FlowSht.1/UnitOpObject.400(Absorber)/FlowSht.600/UnitOpObject.400(Main Tower)" ":Enum.591.1"  0.000000000000e+000
Specify "FlowSht.1/UnitOpObject.400(Absorber)/FlowSht.600/UnitOpObject.400(Main Tower)/TrayStageData.550" ":Selection.201"  0.000000000000e+000
Specify "FlowSht.1/UnitOpObject.400(Absorber)/FlowSht.600/UnitOpObject.400(Main Tower)/TrayStageData.550" ":Selection.201"  1.000000000000e+000
Specify "FlowSht.1/UnitOpObject.400(Absorber)/FlowSht.600/UnitOpObject.400(Main Tower)/TrayStageData.550" ":Selection.201"  3.000000000000e+000
Specify "FlowSht.1/UnitOpObject.400(Absorber)/FlowSht.600/UnitOpObject.400(Main Tower)/TrayStageData.550" ":Selection.201"  2.000000000000e+000

值 0、1、3 和 2 代表内部柱类型 Sieve、Valve、Bubble Cap 和 Packed。

以下代码适用于该规范:

Dim hyfs As Flowsheet
Dim hyfsBD As BackDoor
Dim hyBDVar As RealVariable

Set hyfs = hycase.Flowsheet
Set hyfsBD = hyfs

Set hyBDVar = hyfsBD.BackDoorVariable("UnitOpObject.400(Absorber)/FlowSht.600/UnitOpObject.400(Main Tower)/TrayStageData.550:Selection.201").Variable

hyBDVar.SetValue 1, ""

在这种情况下,该列被指定为阀列。

选择填充柱类型时,可以使用此后门变量来选择填充材料:

hyBDVar = hyfsBD.BackDoorVariable("UnitOpObject.400(Absorber)/FlowSht.600/UnitOpObject.400(Main Tower):ExtraData.523.0).Variable

内部规范的其他名称可以通过记录脚本并改变子流程中的规范来找到。

剩下的问题是如何访问水力图,如何制定这些图的规范以及为什么问题中提到的后门变量对此不起作用。但我会为此发布一个新问题。

于 2019-01-08T08:47:25.963 回答