Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hello
I'm tryin to make VBA excel that
open the displacement table
filter the desired node (ex : 2329 2330 2331 2332 2333 2334)
filter also the cases by name groupe (ex : Raideur)
untill now i cant find the methode to apply the filter to Robot
code :
Sub OpenNodeDisplacementsTableWithSelection()
' Initialize Robot Application
Dim robApp As IRobotApplication
On Error Resume Next
Set robApp = New RobotApplication
On Error GoTo 0
' Open the Node Displacements Table
Dim table As IRobotTable
Set table = robApp.Project.ViewMngr.CreateTable(IRobotTableType.I_TT_NODE_DISPLACEMENTS, I_TDT_DEFAULT)
' Convert node collection to a comma-separated string
Dim nodeNumbersStr As String
nodeNumbersStr = "2329,2330,2331,2332,2333,2334" ' Node numbers to select
' Select the specified nodes
Dim nodeSelection As IRobotSelection
Set nodeSelection = robApp.Project.Structure.Selections.Create(I_OT_NODE)
nodeSelection.FromText nodeNumbersStr ' here where i want to Apply the selection
' Filter cases by group
Dim caseGroup As IRobotGroup
Dim groupServer As IRobotGroupServer
Set groupServer = robApp.Project.Structure.Groups
' Get the number of groups for cases
Dim groupCount As Integer
groupCount = groupServer.GetCount(I_OT_CASE)
' Iterate through all groups to find the one with the matching name
Dim i As Integer
For i = 1 To groupCount
Dim currentGroup As IRobotGroup
Set currentGroup = groupServer.Get(I_OT_CASE, i)
If currentGroup.Name = "Raideur" Then
Set caseGroup = currentGroup
Exit For
End If
Next i
' Check if the group was found
If caseGroup Is Nothing Then
MsgBox "Case group 'Raideur' not found.", vbExclamation, "Error"
Exit Sub
End If
' Set the cases for the table based on the group
Dim caseList As IRobotCaseList
Set caseList = robApp.Project.Structure.Cases.GetAll()
Dim caseSelection As IRobotSelection
Set caseSelection = robApp.Project.Structure.Selections.Create(I_OT_CASE)
caseSelection.FromText caseGroup.GetCases().ToText() ' here my problem Apply the selection
' Refresh the view manager to update the display
robApp.Project.ViewMngr.Refresh
End Sub
Solved! Go to Solution.