在ABD的Mechanical模块中AHU(Air Handle Unit,即空调箱)是比较常用的组件。下面的VBA代码就是以提取AHU参数为例作为演示。
1、在创建的VBA项目中引用(Reference)AECOsim Mechanical Component API 3.0
2、使用如下代码提取AHU参数。假定该AHU组件的ElementID为9948,如果不是该值,请自行修改代码中的数值。所有Mechanical组件的参数都保存在一个叫做BMParameterSet的类中,获得该对象后就能取得各种参数了。
Sub BBMS_ReadParameters() Dim oApp As New BMApplication Dim oElem As Element Dim oParamSet As BMParameterSet Set oElem = ActiveModelReference.GetElementByID(DLongFromLong(9948)) Set oParamSet = oApp.CreateParameterSetFromElement(oElem, True) MsgBox "CatalogType = " & oParamSet.CatalogType & vbCrLf & _ "CatalogItem = " & oParamSet.CatalogItem & vbCrLf & _ "CustomSchemaName = " & oParamSet.CustomSchemaName MsgBox "Custom Parameters:" & vbCrLf & _ " AHU Width = " & oParamSet.Get(bmdParameterGroupCustom, "AHUWidth") & vbCrLf & _ " AHU Height = " & oParamSet.Get(bmdParameterGroupCustom, "AHUHeight") & vbCrLf & _ " Total Length = " & oParamSet.Get(bmdParameterGroupCustom, "TotalLength") MsgBox "EndSpec1_1 Parameters:" & vbCrLf & _ " W1 = " & oParamSet.Get(bmdParameterGroupEndData, "End1/@width") & vbCrLf & _ " D1 = " & oParamSet.Get(bmdParameterGroupEndData, "End1/@depth") End Sub
3、以上代码输出结果如下: