382x
002114
2020-12-14

[ZH] 常见问题 004869 | 如何通过 COM 接口读出截面的合成结果...

问题:
如何通过 COM 接口读出截面的合力?

答案:
截面的合力可以像所有其他结果一样通过 IModel3 → ICalculation2 → IResults2 读出。 结果的接口由 GetResultant 函数提供,该函数在指定结果分布的截面编号和类型时返回 ResultantForce 结构体。 该结构包括力和弯矩作为向量:

子获取结果部分()
    Dim iApp As RFEM5.Application
    Dim iModel As RFEM5.model
    Set iModel = GetObject(, "RFEM5.Model")

    出错时转到 e

    ' 从模型中获取接口
    设置 iApp = iModel.GetApplication
    iApp.LockLicense

    ' 计算得到接口
    Dim iCalc As RFEM5.ICalculation2
    设置 iCalc = iModel.GetCalculation

    ' 从荷载工况 1 的结果中获取接口
    将 iRes 变暗为 RFEM5.IResults2
    设置 iRes = iCalc.GetResultsInFeNodes(LoadCaseType, 1)

    ' 得到结果
    Dim Section_resultant As ResultantForce
    Section_resultant = iRes.GetResultant(1, AtNo, ConstantDistributionOnElements)

e:
如果 Err.Number 0 则
    MsgBox Err.Number & " " & Err.description
End If

如果不是 iApp 那么
    iApp.UnlockLicense
End If

末端接头