Uniform moment in bar in local coordinate system with API

Uniform moment in bar in local coordinate system with API

LuisCRodrigues
Advocate Advocate
2,078 Views
4 Replies
Message 1 of 5

Uniform moment in bar in local coordinate system with API

LuisCRodrigues
Advocate
Advocate

Hi all,
I'm trying to generate uniform loads and uniform moments in bars with API.
For uniform loads, the member "I_BURV_LOCAL" defines if the loads values refer to the global or local coordinate system.
For uniform moments, it seems we can only create load records in the global coordinate system with API.
Does anyone know how to impose the local coordinate system?

Thanks in advance.

 

0 Likes
Accepted solutions (2)
2,079 Views
4 Replies
Replies (4)
Message 2 of 5

Stephane.kapetanovic
Mentor
Mentor
Accepted solution

hi @LuisCRodrigues 

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

Stephanekapetanovic_0-1673361705544.png

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 !
EESignature
0 Likes
Message 3 of 5

LuisCRodrigues
Advocate
Advocate

Hi@Stephane.kapetanovic 

This is a very interesting approach.
Thanks for your help.

Message 4 of 5

Stephane.kapetanovic
Mentor
Mentor
Accepted solution

msg 2 updated

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 !
EESignature
Message 5 of 5

LuisCRodrigues
Advocate
Advocate

I understand you corrected how the moments in the local coordinate system are translated to the global coordinate system. I was precisely working in the same direction.
Thank you for your time. This will be very helpful.

It's just a workaround, but the real question is why the API can't set the load as local as it does for others.

To be seen by Autodesk Team? Maybe @Rafal.Gaweda could comment.