How to add loads to a robot group selection (API)

How to add loads to a robot group selection (API)

rbaXBU6W
Contributor Contributor
977 Views
3 Replies
Message 1 of 4

How to add loads to a robot group selection (API)

rbaXBU6W
Contributor
Contributor

Hi All

 

I would like to add a simple uniform load to a group of elements (Bars) that i have in my model through API. 

I cannot seem to find any code that works... Can anyone help?

 

 

0 Likes
Accepted solutions (2)
978 Views
3 Replies
Replies (3)
Message 2 of 4

Stephane.kapetanovic
Mentor
Mentor
Accepted solution

hi @rbaXBU6W 

Sub Apply_UniformLoad_To_Bars_List()
  Dim RobApp As IRobotApplication
  Set RobApp = New RobotApplication
  
  Dim Cases As RobotCaseServer
  Dim Cas As IRobotSimpleCase
  Set Cases = RobApp.Project.Structure.Cases
  Set Cas = Cases.CreateSimple(1, "UNIFORM_LOAD", I_CN_EXPLOATATION, I_CAT_STATIC_LINEAR)
  
  Dim Rec As IRobotLoadRecord
  Set Rec = Cas.Records.Create(I_LRT_BAR_UNIFORM)
  Rec.SetValue IRobotBarUniformRecordValues.I_BURV_PZ, -1000
  Rec.Objects.FromText "1 2 3 4"
  
  RobApp.Project.ViewMngr.Refresh
  Set RobApp = Nothing
End Sub

Best regards

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
0 Likes
Message 3 of 4

rbaXBU6W
Contributor
Contributor

Hi @Anonymous
Thanks for the help, but i need to assign the load to a group of bar members not choose the bars manually like your code

0 Likes
Message 4 of 4

Stephane.kapetanovic
Mentor
Mentor
Accepted solution

hi @rbaXBU6W 

Add this function to search the group list of bars by its name : 

Function GetListByGroup(RobApp As IRobotApplication, GroupName As String) As String
  Dim GroupBars As RobotGroup
  Dim RGroups As RobotGroupServer: Set RGroups = RobApp.Project.Structure.Groups
  Dim BarType As IRobotObjectType:  BarType = IRobotObjectType.I_OT_BAR
  Dim GroupBarsCnt As Integer: GroupBarsCnt = RGroups.GetCount(BarType)
  For i = 1 To GroupBarsCnt
    Set GroupBars = RGroups.Get(BarType, i)
    If GroupBars.name = GroupName Then
      GetListByGroup = GroupBars.SelList: Exit Function
    End If
  Next i
  GetListByGroup = ""
End Function

Modify previous code as follow:

Sub Apply_UniformLoad_To_Bars_List()
(...)

' Rec.Objects.FromText "1 2 3 4" < Previous Line
  Dim GroupName As String
  GroupName = "Rafter" 
  Rec.Objects.FromText GetListByGroup(RobApp, GroupName)
 
(...)
End Sub

Result:

Stephanekapetanovic_1-1635831915696.png

Best regards

 

See also https://forums.autodesk.com/t5/robot-structural-analysis-forum/robot-api-apply-load-to-a-chain-of-ba...

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
0 Likes