How to change the background color in 3Dexperience with a VBA macro
It can be quote useful to be able to quickly change the background color to a specific color (like black or white) at the click of a button. In CATIA V5, here’s how you get the current background color:
Dim vColorArray(2) As Vriant
Dim oViewer As Object
Set oViewer = CATIA.ActiveWindow.ActiveViewer
oViewer.GetBackgroundColor vColorArray
And to change the background color in V5:
Dim oViewer As Object
Set oViewer = CATIA.ActiveWindow.ActiveViewer
oViewer.PutBackgroundColor Array ((65/255),(60/255),(100/255))
The background colors are represented in RGB color mode with values ranging from 0 to 1 for red, green, and blue. For example, black is 0,0,0.
In CATIA V6, you can use the same code as in V5 to change the background color, the only difference is first you need to set the Ambience to “Basic.” So add this to the beginning:
CATIA.StartCommand(“Basic”)
If you found this article helpful, please let us know in the comments below so we know to write more of them!