Working on a project that makes use of the model environment through the recent Rhino components in Grasshopper. I have some randomly generated panels that i can cycle through. With some python code+trigger i check if a panel is selected, which is stored as a boolean value/key in the Object.
Now i want to try and disable the gumball whenever a panel is selected, because at that point i want to show some annotation/information. The gumball comes in use again later under different conditions, so i need to enable it again when the boolean is false.
I have this code through chatgpt, but so far no luck. Does anyone see the problem?
import Rhino
import scriptcontext as sc
import rhinoscriptsyntax as rs
# Input: isSelected (bool) -- True to turn Gumball ON, False to turn OFF
def toggle_gumball(is_selected):
# Get the current document's GumballDisplayConduit
gumball = Rhino.UI.Gumball.GumballDisplayConduit()
# Enable or disable the Gumball based on selection state
gumball.Enabled = is_selected
# Redraw the views to update the display
Rhino.RhinoDoc.ActiveDoc.Views.Redraw()
toggle_gumball(isSelected)
Panels_Redux.gh (14.6 KB)