473x
005058
2021-08-24

Rotation of Nodal Support Using COM Interface

How can I rotate a nodal support using the COM interface?


Answer:

The rotation of a nodal support is defined by means of a user-defined coordinate system. In the following example, a nodal support is rotated 45 ° about the z-axis. It is not necessary to define a new coordinate system via nodes. In this case, it is sufficient to use the RotatedSystemType option, which allows for spatial rotation of the support via three rotations about the x-, y-, and z-axes. The rotation is entered in radians:


Sub test_nodal_support()

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

iApp.LockLicense

Dim iMod As RFEM5.IModel3
Set iMod = iApp.GetActiveModel

On Error GoTo e

'   get interface of modeldata
Dim iModData As RFEM5.IModelData2
Set iModData = iMod.GetModelData

'   get interface of nodal support
Dim iNs As RFEM5.INodalSupport
Set iNs = iModData.GetNodalSupport(1, AtNo)

'   get nodal support data
Dim ns As RFEM5.NodalSupport
ns = iNs.GetData

'   modify data
ns.ReferenceSystem = UserDefinedSystemType
ns.UserDefinedReferenceSystem.Axis1 = AxisX
ns.UserDefinedReferenceSystem.Axis2 = AxisY
ns.UserDefinedReferenceSystem.Type = RotatedSystemType
ns.UserDefinedReferenceSystem.RotationAngles.X = 0
ns.UserDefinedReferenceSystem.RotationAngles.Y = 0
ns.UserDefinedReferenceSystem.RotationAngles.Z = 45 * 3.14159265359 / 180

'   set nodal support data
iModData.PrepareModification
iNs.SetData ns
iModData.FinishModification

e:

If Err.Number <> 0 Then MsgBox Err.description, vbCritical, Err.Source

iMod.GetApplication.UnlockLicense
Set iMod = Nothing

End Sub


The program takes the existing nodal support from the currently opened model and modifies it. Since the user-defined coordinate system is not a direct part of the INodalSupport interface of the nodal support, the rotation can also be transferred when creating a nodal support, of course.