The purpose of my code is to switch the screen to a white background then switch back to the users unique background color for multiple users (all with different colors). This is done with a toggle button on a userform.
I'm trying to pass the users current screen RGB through an array, but, I'm getting a type mismatch when using getbackgroundRGB. However, I can get getbackgroundcolor to work but it normalizes the values (sets them to a decimal value between 0 and 1)
What is the type mismatch for getbackgroundRGB? Second, it functions when I use getbackgroundcolor but the value resets to 0 when you un-toggle the userform button. Does this happen because of the toggle? How can I store these values??
Example of the issue; the user starts with a grey background, toggles to white then untoggles to black(instead of grey) since the value is now 0,0,0. It needs to function: users unique color --> white --> users unique color
Thanks in advance
Code:
Private Sub ScreenToggle_Click()
Dim ObjViewer3D
Set ObjViewer3D = CATIA.ActiveWindow.ActiveViewer
Dim BackgroundColorSettingControl
Set BackgroundColorSettingControl = CATIA.SettingControllers
Dim ColorVizSetting
Set ColorVizSetting = BackgroundColorSettingControl.Item("CATVizVisualizationSettingCtrl")
[highlight #8AE234]'I want getbackgroundRGB instead of ...Color...or do it??[/highlight]
Dim BackgroundColor(2)
ObjViewer3D.GetBackgroundColor BackgroundColor
'convert normalized value back to 0-255 scale
Dim UserRed
Dim UserGreen
Dim UserBlue
UserRed = BackgroundColor(0) * 255
UserGreen = BackgroundColor(1) * 255
UserBlue = BackgroundColor(2) * 255
'Test if RGB values are passing through
MsgBox ("Background Color Values are R: ") & BackgroundColor(0) & ", G: " & BackgroundColor(1) & ", B: " & BackgroundColor(2)
'MsgBox ("Background Color Values are R: ") & UserRed & ", G: " & UserGreen & ", B: " & UserBlue
If ScreenToggle.Value = True Then
'set color to white
ColorVizSetting.SetBackgroundRGB 255, 255, 255
ColorVizSetting.SaveRepository
End If
[highlight #8AE234]'Red, Green, Blue values are reset back to 0 here, why??[/highlight]
If ScreenToggle.Value = False Then
Set ObjViewer3D = CATIA.ActiveWindow.ActiveViewer
Set BackgroundColorSettingControl = CATIA.SettingControllers
Set ColorVizSetting = BackgroundColorSettingControl.Item("CATVizVisualizationSettingCtrl")
[highlight #8AE234]'test for values passing[/highlight]
MsgBox ("Background Color Values are R: ") & UserRed & ", G: " & UserGreen & ", B: " & UserBlue
ColorVizSetting.SetBackgroundRGB UserRed, UserGreen, UserBlue
ColorVizSetting.SaveRepository
End If
End Sub
I'm trying to pass the users current screen RGB through an array, but, I'm getting a type mismatch when using getbackgroundRGB. However, I can get getbackgroundcolor to work but it normalizes the values (sets them to a decimal value between 0 and 1)
What is the type mismatch for getbackgroundRGB? Second, it functions when I use getbackgroundcolor but the value resets to 0 when you un-toggle the userform button. Does this happen because of the toggle? How can I store these values??
Example of the issue; the user starts with a grey background, toggles to white then untoggles to black(instead of grey) since the value is now 0,0,0. It needs to function: users unique color --> white --> users unique color
Thanks in advance
Code:
Private Sub ScreenToggle_Click()
Dim ObjViewer3D
Set ObjViewer3D = CATIA.ActiveWindow.ActiveViewer
Dim BackgroundColorSettingControl
Set BackgroundColorSettingControl = CATIA.SettingControllers
Dim ColorVizSetting
Set ColorVizSetting = BackgroundColorSettingControl.Item("CATVizVisualizationSettingCtrl")
[highlight #8AE234]'I want getbackgroundRGB instead of ...Color...or do it??[/highlight]
Dim BackgroundColor(2)
ObjViewer3D.GetBackgroundColor BackgroundColor
'convert normalized value back to 0-255 scale
Dim UserRed
Dim UserGreen
Dim UserBlue
UserRed = BackgroundColor(0) * 255
UserGreen = BackgroundColor(1) * 255
UserBlue = BackgroundColor(2) * 255
'Test if RGB values are passing through
MsgBox ("Background Color Values are R: ") & BackgroundColor(0) & ", G: " & BackgroundColor(1) & ", B: " & BackgroundColor(2)
'MsgBox ("Background Color Values are R: ") & UserRed & ", G: " & UserGreen & ", B: " & UserBlue
If ScreenToggle.Value = True Then
'set color to white
ColorVizSetting.SetBackgroundRGB 255, 255, 255
ColorVizSetting.SaveRepository
End If
[highlight #8AE234]'Red, Green, Blue values are reset back to 0 here, why??[/highlight]
If ScreenToggle.Value = False Then
Set ObjViewer3D = CATIA.ActiveWindow.ActiveViewer
Set BackgroundColorSettingControl = CATIA.SettingControllers
Set ColorVizSetting = BackgroundColorSettingControl.Item("CATVizVisualizationSettingCtrl")
[highlight #8AE234]'test for values passing[/highlight]
MsgBox ("Background Color Values are R: ") & UserRed & ", G: " & UserGreen & ", B: " & UserBlue
ColorVizSetting.SetBackgroundRGB UserRed, UserGreen, UserBlue
ColorVizSetting.SaveRepository
End If
End Sub