hi @LuisCRodrigues
here after an example to set local loads (uniform and moment distributed moments)

Sub CreateBarsUniformAndMomentLocalLoad()
Dim RobApp As IRobotApplication: Set RobApp = New RobotApplication
If Not (RobApp.Visible = -1 And RobApp.Project.IsActive = -1) Then
Set RobApp = Nothing: Exit Sub
End If
Dim CasSel As RobotSelection, CasCol As RobotCaseCollection, Cas As IRobotCase, FirstAvailableCase As RobotSimpleCase
Dim Bars As RobotBarServer, Bar As RobotBar, TbForces() As Double: mtx(0 To 2, 0 To 2) As Double
With RobApp.Project.Structure
Set Bars = .Bars
Set CasSel = .Selections.CreatePredefined(I_PS_CASE_SIMPLE_CASES)
Set CasCol = .Cases.GetMany(CasSel)
End With
For i = 1 To CasCol.Count
Set Cas = CasCol.Get(i)
If Cas.AnalizeType <> I_CAT_DYNAMIC_MODAL Then
Set FirstAvailableCase = Cas
With FirstAvailableCase.Records.Create(I_LRT_BAR_UNIFORM)
.Description = "New Uniform Load": .Objects.FromText "1 2": .SetValue IRobotBarUniformRecordValues.I_BURV_PY, -5000: .SetValue I_BURV_LOCAL, 1
End With
With FirstAvailableCase.Records.Create(I_LRT_BAR_MOMENT_DISTRIBUTED)
.Description = "New Distributed Moment Load": .Objects.FromText "3 4": .SetValue IRobotBarMomentDistributedRecordValues.I_BMDRV_MX, -5000
End With
TbBarNos = Array(5, 6)
For j = 0 To UBound(TbBarNos)
BarNo = TbBarNos(j): Set Bar = Bars.Get(BarNo)
Bar.GetLocalMtx mtx(0, 0), mtx(0, 1), mtx(0, 2), mtx(1, 0), mtx(1, 1), mtx(1, 2), mtx(2, 0), mtx(2, 1), mtx(2, 2)
TbForces = SetForces(0, 0, 0, -5000, 0, 0): Transform TbForces, Invert(mtx)
With FirstAvailableCase.Records.Create(I_LRT_BAR_MOMENT_DISTRIBUTED)
.Description = "New Distributed Moment Load - Local": .Objects.FromText Str(BarNo)
.SetValue I_BMDRV_MX, TbForces(3): .SetValue I_BMDRV_MY, TbForces(4): .SetValue I_BMDRV_MZ, TbForces(5)
End With
Next j
Exit For
End If
Next i
Set RobApp = Nothing
End Sub
Function SetForces(Fx As Double, Fy As Double, Fz As Double, Mx As Double, My As Double, Mz As Double) As Double()
Dim TbForces(0 To 5) As Double: Tb = Array(Fx, Fy, Fz, Mx, My, Mz)
For I = 0 To 5: TbForces(I) = Tb(I): Next
SetForces = TbForces
End Function
Function Invert(m() As Double) As Double()
Dim rm(0 To 2, 0 To 2) As Double
For I = 0 To 2
For j = 0 To 2: rm(I, j) = m(j, I): Next j
Next
Invert = rm
End Function
Sub Transform(v() As Double, m() As Double)
Dim vt(0 To 5) As Double
For I = 0 To 2
For j = 0 To 2
cm = m(I, j): vt(I) = vt(I) + v(j) * cm: vt(I + 3) = vt(I + 3) + v(j + 3) * cm
Next j
Next I
For I = 0 To 5: v(I) = vt(I): Next I
End Sub
Function GetLocalMtx(x_ As RobotGeoPoint3D, y_ As RobotGeoPoint3D, z_ As RobotGeoPoint3D) As Double()
Dim m(0 To 2, 0 To 2) As Double
m(0, 0) = x_.X: m(0, 1) = x_.Y: m(0, 2) = x_.Z: m(1, 0) = y_.X: m(1, 1) = y_.Y: m(1, 2) = y_.Z: m(2, 0) = z_.X: m(2, 1) = z_.Y: m(2, 2) = z_.Z
GetLocalMtx = m
End Function
Best Regards
Stéphane Kapetanovic
Did you find this post helpful? If it gave you one or more solutions,
don't forget to click the Accept Solution button and leave a < like !
