Feature Flags in Components

I’m creating some new components for a Grasshopper Plugin, they are however, much more experimental and I’d like to avoid every use having access, so I’ve opted to use feature flags to prevent anyone without the flag toggled on accessing the newer components.

We already have a feature flag system set up, but when I’m struggling to figure out is a way to avoid Grasshopper loading in certain components. Is there a way to prevent a component from loading into the Ribbon so users cannot add it to the document?

I’ve worked out that I can toggle the parameters loading that prevents users using them, but this is not ideal.

And, as a stretch goal, is there a way of dynamically changing this?

– cs

Hi,

It’s a bit counter-intuitive, but you could set your components to Obsolete.
Just add _OBSOLETE in the GH_Component class name.

This way they load but are not shown in the ribbon. You can still access those if you search #ComponentName in the search bar.

Hey @magicteddy,

I searched the forums to find this _OBSOLETE class appendage to see what it does and fount this snippet;

Long Quote

So I tried overriding Exposure like this, which works perfectly!

public override GH_Exposure Exposure
{
	get
	{
		if (FeatureFlagIsEnabled)
		{
			return base.Exposure;
		}
		else
		{
			return GH_Exposure.hidden;
		}
	}
}
1 Like