Hello,
I am trying to use RS 5.12 and VSTA to make a GraphicComponent visible and non visible. I have been looking at the examples in VSTA but it is not getting me anywhere. If anyone has done this and doesn’t mind sharing their code would you please help out. Below is what I have thus far and it does not work.
Dim PartIndex As Integer = 0
Dim PalletBox As Object
’ This method is called when the addin is loaded into RobotStudio.
Public Sub AddInStartup()
’ TODO: Add startup code here. Create toolbars, etc.
End Sub
’ This method is called when the addin is unloaded from RobotStudio.
Public Sub AddInShutdown()
’ TODO: Add cleanup code here. Remove toolbars, etc.
End Sub
’ Default sample Macro. Can be removed.
’ Note: A Macro is defined as a “Public Sub” method, with
’ no arguments and with a name that starts with “Macro_”
’ Other methods will not be visible from the Addin Browser.
Public Sub Macro_Sample1()
’ TODO: Define actions to perform when the Macro is invoked.
’ Logger.AddMessage(New LogMessage(“Macro_Sample1 output window message.”))
End Sub
Public Sub Macro_ShowPart()
’ Check that we have an active project
If Project.ActiveProject Is Nothing Then
Exit Sub
End If
’ Get the currently selected object
Dim selObject As Object = Project.ActiveProject.Selection.SingleSelectedObject
If PartIndex = Nothing Then
PartIndex = 1
End If
'selObject = TryCast(PalletBox, GraphicComponent)
'Define GraphicComponent
'Select part to Show
Select_Part()
’ Create two parts
Dim GraphicBox As New Part()
GraphicBox.Name = PalletBox
Dim gc As GraphicComponent = TryCast(sel, GraphicComponent)
gc.Name = PalletBox
'gc = GraphicBox
'Make the part visible
gc.Visible = Not gc.Visible
PartIndex += 1
End Sub
Public Sub Select_Part()
Select Case PartIndex
Case 1
PalletBox = “Pallet_1_Box_1”
Case 2
PalletBox = “Pallet_1_Box_3”
Case 3
PalletBox = “Pallet_1_Box_123”
Case 4
PalletBox = “Pallet_1_Box_1_2”
Case 5
PalletBox = “Pallet_1_Box_3_2”
Case 6
PalletBox = “Pallet_1_Box_123_2”
Case 7
PalletBox = “Pallet_1_Box_1_3”
Case 8
PalletBox = “Pallet_1_Box_3_3”
Case 9
PalletBox = “Pallet_1_Box_123_3”
Case 10
PalletBox = “Pallet_1_Box_1_4”
Case 11
PalletBox = “Pallet_1_Box_3_4”
Case 12
PalletBox = “Pallet_1_Box_123_4”
Case 13
PalletBox = “Pallet_1_Box_1_5”
Case 14
PalletBox = “Pallet_1_Box_3_5”
Case 15
PalletBox = “Pallet_1_Box_123_5”
Case 16
PalletBox = “Pallet_1_Box_1_6”
Case 17
PalletBox = “Pallet_1_Box_3_6”
Case 18
PalletBox = “Pallet_1_Box_123_6”
Case 19
PalletBox = “Pallet_1_Box_1_7”
Case 20
PalletBox = “Pallet_1_Box_3_7”
Case 21
PalletBox = “Pallet_1_Box_123_7”
Case 22
PalletBox = “Pallet_1_Box_1_8”
Case 23
PalletBox = “Pallet_1_Box_3_8”
Case 24
PalletBox = “Pallet_1_Box_123_8”
Case 25
PalletBox = “Pallet_1_Box_1_9”
Case 26
PalletBox = “Pallet_1_Box_3_9”
Case 27
PalletBox = “Pallet_1_Box_123_9”
End Select
End Sub
Thanks for the help,
Rick