543x
001711
2020-08-12

[EN] FAQ 004622 | How can I enter or read out a response spectrum via the COM interface in DYNAM...

Question:
How can I enter or read out a response spectrum via the COM interface in DYNAM Pro?

Answer:
The COM interface allows you to read out or create a user-defined response spectrum in RFEM and RSTAB.

For the conversion, the interface to the module (IDynamModule) must first be retrieved via the interface to the RFEM model (IModel). This interface is then used to create the module case (IModuleCase). IModuleCase includes the GetRSParams function, which can be used to read out the parameters for the response spectrum. On the other hand, the SetRSParams function can write new data. The following example code clarifies it:

Dim iApp As RFEM5.Application
Dim iMod As RFEM5.model
Set iApp = GetObject(, "RFEM5.Application")

Dim rs_no As Integer
rs_no = 1

On Error GoTo e

    ' Checks RS-COM license and locks the application for using by COM.
    iApp.LockLicense

    Set iMod = iApp.GetActiveModel

    ' get module interface
    Dim iDyn As IDynamModule
    Set iDyn = iMod.GetModule("DynamPro")

    ' get module case interface
    Dim iDynCase As IModuleCase
    Set iDynCase = iDyn.GetData

    '  set response spectra parameters
    Dim rspara As RSParams
    rspara = iDynCase.GetRSParams(rs_no)

    Dim rs_spec(0 To 10) As RSTableRow

    Dim index As Integer
    index = 0
    rs_spec(index).s = 0.6
    rs_spec(index).T = 0

    index = 1
    rs_spec(index).s = 1.33
    rs_spec(index).T = 0.153

    index = 2
    rs_spec(index).s = 1.33
    rs_spec(index).T = 0.4

    index = 3
    rs_spec(index).s = 1.204
    rs_spec(index).T = 0.443

    index = 4
    rs_spec(index).s = 1.07
    rs_spec(index).T = 0.5

    index = 5
    rs_spec(index).s = 0.7
    rs_spec(index).T = 0.761

    index = 6
    rs_spec(index).s = 0.508
    rs_spec(index).T = 1.051

    index = 7
    rs_spec(index).s = 0.367
    rs_spec(index).T = 1.453

    index = 8
    rs_spec(index).s = 0.267
    rs_spec(index).T = 1.995

    index = 9
    rs_spec(index).s = 0.16
    rs_spec(index).T = 2.584

    index = 10
    rs_spec(index).s = 0.16
    rs_spec(index).T = 5

    rspara.UserDefinedTable = rs_spec
    rspara.Comment = "test rs"
    rspara.DefinitionType = ResponseSpectraType.UserDefinedRS
    rspara.description = "test rs via COM"
    rspara.Number = rs_no

    iDynCase.SetRSParams rs_no, rspara

e:  If Err.Number 0 Then MsgBox Err.description, , Err.Source

    iMod.GetApplication.UnlockLicense
    Set iMod = Nothing
    Set iApp = Nothing

The response spectrum was created according to EN 1998‑1:2010 and has 11 points. First, an array of the RSTableRow type with 11 elements was created, filled with data, and then saved under the UserDefinedTable property. The transfer is carried out using the SetRSParams command.



;