Change Rhino background colour from GHPython?

ghpython
python
rhino5

(P1r4t3b0y) #1

Hi,

Would changing the colour of the Rhino canvas/background be possible from the GHPython component?
And if so, how? I would also be interested in turning the grid on and off in GHPython.

The colour and grid display shouldn’t be changed permanently, but should roll back to their defaults, when the next Grasshopper script or Rhino file are opened.

Any ideas, guys?

Thank you and have a nice week-end everybody!


(Wim Dekeyser) #2

This might help:


(P1r4t3b0y) #3

Thanks, however I’m not looking for a solution to change the Grasshopper canvas, but the Rhino background and grid from GHPython. Any ideas?


#4

You can set these from GHPython through Rhino.ApplicationSettings.AppearanceSettings. You probably want the ViewportBackgroundColor property.


(P1r4t3b0y) #5

When I call print ra.AppearanceSettings.ViewportBackgroundColor it seems to print the rgba values for the current background, which is great.
However, when I try to change the background, by calling ra.AppearanceSettings.ViewportBackgroundColor(my_colour), where my_colour is a swatch input, it tells me that “color is not callable”.

Do you you know what I’m doing wrong here. The documentation states that it should be able to set and get the background colour.


#6

Since it’s a property (i.e. not a method) you assign it using an equals sign.


(P1r4t3b0y) #7

Thank you, it works perfectly.