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.
Solved! Go to Solution.
Solved by Stephane.kapetanovic. Go to Solution.
Solved by Stephane.kapetanovic. Go to Solution.
here after an example to set local loads (uniform and moment distributed moments)
Sub CreateBarsUniformAndMomentLocalLoad()
Dim RobApp As IRobotApplication
Set RobApp = New RobotApplication
Visible = RobApp.Visible = -1
IsActive = RobApp.Project.IsActive = -1
Ready = Visible And IsActive
If Not Ready Then
Set RobApp = Nothing: Exit Sub
End If
Dim RSel As RobotSelection, AllCasCol As RobotCaseCollection
Dim Cas As IRobotCase, FirstAvailableCase As RobotSimpleCase
Dim LoadRecord As IRobotLoadRecord
Dim RecAT As IRobotCaseAnalizeType
Dim Bars As RobotBarServer, Bar As RobotBar
Dim TbForces() As Double
Dim mtx(0 To 2, 0 To 2) As Double
With RobApp
With .Project.Structure
Set RSel = .Selections.CreatePredefined(I_PS_CASE_SIMPLE_CASES)
Set AllCasCol = .Cases.GetMany(RSel)
Set Bars = .Bars
End With
End With
For I = 1 To AllCasCol.Count
Set Cas = AllCasCol.Get(I)
RecAT = Cas.AnalizeType
If RecAT <> I_CAT_DYNAMIC_MODAL Then
Set FirstAvailableCase = Cas
' Uniform Load
' --------------
With FirstAvailableCase.Records.Create(I_LRT_BAR_UNIFORM)
.Description = "New Uniform Load"
.Objects.FromText "1 2"
' IRobotBarUniformRecordValues
.SetValue I_BURV_PY, -5000
.SetValue I_BURV_LOCAL, 1 ' < Local Load 0 = false, 1 = true
End With
' Global Moments
' --------------
With FirstAvailableCase.Records.Create(I_LRT_BAR_MOMENT_DISTRIBUTED)
.Description = "New Distributed Moment Load"
.Objects.FromText "3 4"
' IRobotBarMomentDistributedRecordValues
.SetValue I_BMDRV_MX, -5000
End With
' Local Moments
' --------------
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) ' To Local
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()
Tb = Array(Fx, Fy, Fz, Mx, My, Mz)
Dim TbForces(0 To 5) As Double
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
Best Regards
This is a very interesting approach.
Thanks for your help.
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.
Can't find what you're looking for? Ask the community or share your knowledge.