Managing changes in input parameters during GH file read for custom C# GH_Component

I wrote a few custom components for grasshopper in C#, used them on a canvas, and saved to a grasshopper file. I’m now tweaking the components and removing some input parameters and adding new ones. When the GH file is opened grasshopper shows an error


info: Plugin version: 1.0.0007
error: Input parameter chunk is missing. Archive is corrupt.
error: Input parameter chunk is missing. Archive is corrupt.
error: Input parameter chunk is missing. Archive is corrupt.
info: Object list read

Once loaded I get the original set of input parameters on the canvas component. To get the canvas working again I have to manually replace the loaded component with a fresh one (which has the new input params) and rewire.

There must be a better way :slight_smile: I suspect I need to override the Read on my GH_Component classes and handle this as a version change to the component, but need some sample code to dive in.

Are you inheriting from IGH_VariableParameterComponent Interface? The GH_Component already takes care of (de)serialising the parameters.

I’m just inheriting from GH_Component. The input parameters are intended to be fixed, but decided to make a breaking change and remove one of the inputs. Trying to figure out if there is an elegant way to handle the removal of the input parameter when reading an old GH file.

For the GH file I’m reading there are no wires connected to the input parameter I removed.

Ups sorry I misunderstand you, ignore my last comment. You have to mark the old version of the component as obsolete and create a new one with another component ID, instead of replace the code as you did.

1 Like