by Tuğrul Yazar | August 8, 2023 11:07
Recently I found this VB.net component in an old Grasshopper[1] project. I am not sure if it is mine or not, but I wanted to share it with you. This code modifies Rhino viewport colors quickly without entering the Rhino options window. I frequently modify the viewport colors and grid settings to create renders or animations within Grasshopper. This is why, this component might be useful in making quick modifications to the screen colors. Here is the VB.net code inside of the component:
Private Sub RunScript(ByVal D As Boolean, ByVal B As System.Drawing.Color, ByVal G As System.Drawing.Color)
If D = True Then
Rhino.ApplicationSettings.AppearanceSettings.ViewportBackgroundColor = Color.FromArgb(0, 157, 163, 170)
End If
If D = False Then
Rhino.ApplicationSettings.AppearanceSettings.ViewportBackgroundColor = B
End If
Rhino.ApplicationSettings.AppearanceSettings.GridThickLineColor = G
Rhino.ApplicationSettings.AppearanceSettings.GridThinLineColor = G
Rhino.ApplicationSettings.AppearanceSettings.GridXAxisLineColor = G
Rhino.ApplicationSettings.AppearanceSettings.GridYAxisLineColor = G
Rhino.ApplicationSettings.AppearanceSettings.GridZAxisLineColor = G
End Sub
As you can see, it only has several conditional statements, modifying the methods from Rhinocommon. And here is the Grasshopper definition if you want to try it:
You can copy and paste this component into your definition. It should work immediately, modifying the Rhino settings. By switching the first input (Default), you can always revert back to the default Rhino viewport colors. However, unfortunately, I couldn’t find a method to hide the grid. Thus, if you want to close the grid, you can just connect the same viewport background color to the grid color as a workaround.
It would be interesting to advance this more by reading Rhinocommon[3] and developing a better and more capable add-on for Grasshopper. In addition to Rhino viewport colors and grid settings, some other options can be better altered via a similar component. I am not sure I have enough time for this but maybe one day I can work on it. However, I hope this is already useful for some people. Maybe a Grasshopper Python equivalent might be another good exercise.
Source URL: https://www.designcoding.net/rhino-viewport-colors/
Copyright ©2024 designcoding unless otherwise noted.