Adjust Viewport colours with Python?


#1

Is this possible, change Viewport colours with a python script, then restore to default?

Thanks,
Randy


(Dale Fugier) #2

Hi Randy,

Check the Rhino.Python help file for the AppearanceColor() function.

– Dale


#3

It’s certainly possible to change the viewport color via AppearanceColor() as Dale said, but it’s not easy to get back to the original color - unless you’re in the same session, then it could be stored as a “sticky” value. But when you quit the current session, that value will be lost. Another possibility would be to write an external file somewhere to get back to your “standard” value, or, if you know you always want the same color, you can just program that into the script as a choice.

–Mitch


#4

Thanks Dale and Mitch,

I was looking for Viewport or color in the help, never thought of appearance.

i just would like to change background, grid, X & Y lines to white to take screen shots of object’s 2D lines. Usually between 10 - 20 Rhino files at a time, once every week or 2.

It usually is in the same session, the restore is not as much of an issue as it is just one click instead of 10 to change colours. Trying to learn & save time.

Probably try this tomorrow at work, Thanksgiving here, so today is a holiday … off for roast beast!

… Randy


#5

I seem to recall you’re on Mac - if so, don’t bother. As far as I can tell, rs.AppearanceColor() is not yet hooked up on Mac. At least it throws an exception here when I run a test script (that runs on Windows).

–Mitch


#6

Thanks Mitch, I am most of the time. I will try it on my Windows machine tomorrow, just to see.

I am getting an exception here as well :frowning:

Randy


(Tim) #7

Hi, thanks for the note.
I’m kinda new to scripting in Python, but I really wanted to make a night mode button for Rhino so I thought it would be easy enough for me to write the script and have a little project.

There is one problem though:


I’d like to double check if it’s still the case or rather a missed leftover and the feature has been already updated?


#8

The above method only shows or hides the items, nothing to do with their display color… Most of those can be done with macros as well. To get at toolbar background colors and the like, you would need to go into RhinoCommon as far as I know:

http://developer.rhino3d.com/api/RhinoCommonWin/html/T_Rhino_ApplicationSettings_PaintColor.htm

Via scripting you can change the viewport background color - if it’s not overridden by a custom display mode - as well as other elements of the viewport display; plus the command line background color. Check the rs.AppearanceColor() method for those.

–Mitch


(Tim) #9

Hi Mitch,
Thank you for your reply. I can see AppearanceColor() in Python here but I don’t think I can change the color of these guys:


After some looking around I found what you mentioned in Rhino.ApplicationSettings.PaintColor()

Have little idea about how to use it, but I’ll try to find some examples and hopefully things will start moving.
Thanks!


#10

Yes, you can - well, most of them:

Looks like you can’t change the Z-Axis color, the world X,Y,Z small icon colors, or the layout background with that. For those items you do need to work directly in RhinoCommon - for V5 at least, don’t know if these will be added to rhinoscriptsyntax for V6 or not.

–Mitch


(Tim) #11

Ooops, sorry for confusion, I meant these, since they change the color of all the bars and borders:


#12

Yep, those you need to use RhinoCommon Rhino.ApplicationSettings.AppearanceSettings.SetPaintColor() method (as linked above) - but I don’t know exactly which items correspond to the different items in Options>Appearance>Colors, so I guess a little experimentation will be necessary.

–Mitch


(Tim) #13

That’s ok, the link you provided is really helpful, it shows the numbers and the values.