584x
002429
2021-03-10

FAQ 004967 | How can I create a nodal support with a nonlinearity diagram via the COM interface?

Question:
How can I create a nodal support with a nonlinearity diagram via the COM interface?

Answer:
The following VBA macro shows the creation of a nodal support with a nonlinearity diagram. The source code can be found under Downloads.

'--------------------------------------------------------------------------------------------------
Sub SetNSupports()
'--------------------------------------------------------------------------------------------------
Dim model As RFEM5.model
Dim data As IModelData
Dim support(0) As RFEM5.NodalSupport
Dim ISup As RFEM5.INodalSupport
Dim ISupDia As RFEM5.INonlinearityDiagram
Dim nlDiag As NonlinearityDiagram
Dim zone(2, 1) As Double

    Set model = GetObject(, "RFEM5.Model")
    model.GetApplication.LockLicense

    On Error GoTo e

    Set data = model.GetModelData

    support(0).No = 1
    support(0).nodelist = "1"
    support(0).SupportNonlinearityX = WorkingDiagramType
    support(0).SupportConstantY = -1
    support(0).SupportConstantZ = -1
    support(0).RestraintConstantX = -1
    support(0).RestraintConstantY = -1
    support(0).RestraintConstantZ = -1

    data.PrepareModification
    data.SetNodalSupports support
    data.FinishModification

    Set ISup = data.GetNodalSupport(1, AtNo)
    Set ISupDia = ISup.GetNonlinearity(AlongAxisX)

    zone(0, 0) = 0
    zone(0, 1) = 0
    zone(1, 0) = 1
    zone(1, 1) = 2
    zone(2, 0) = 3
    zone(2, 1) = 4

    nlDiag.PositiveZoneType = DiagramAfterLastStepType.StopDiagramType
    nlDiag.PositiveZone = zone
    nlDiag.Symmetric = True

    data.PrepareModification
    ISupDia.SetData nlDiag
    data.FinishModification

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

    Set data = Nothing
    model.GetApplication.UnlockLicense
    Set model = Nothing

End Sub



;