How to hide an input parameter

Hi All,
I am registering two input parameters to record the values of the sliders (custom attributes) in the component. everything works fine and I just need to hide those parameters so user can only interact with sliders. the method
pManager.HideParameter(index);

does not do anything , any idea?

Do not register them in RegisterInputParams().

Then how can I save the current value in the GH file without having a parameter registered ?

Override Write() and Read() to serialize and deserialize your data. Any other automatic behaviour that the parameters do, you will have to replace them yourself if needed. As far as I know you can’t register a parameter and not have it appear in the capsule.

1 Like

Thanks Dani, I am new to GH_IWriter Interface , can you point me to a sample code or an implementation example.

        private double _sliderValue1; 
        public override bool Write(GH_IWriter writer)
        {
            writer.SetDouble(nameof(_sliderValue1), _sliderValue1);
            return base.Write(writer);
        }
        public override bool Read(GH_IReader reader)
        {
            if (reader.ItemExists(nameof(_sliderValue1)))
                _sliderValue1 = reader.GetDouble(nameof(_sliderValue1));
            return base.Read(reader);
        }
1 Like

Thanks a lot
It was simpler than what I expected ,
Just one more thing , the Read() method gets called before solution update or there is mechanism to call it manually?

It is called automatically and shouldn’t be used manually in most cases.
Though I’d recommend SetValue/GetValue rather than overriding Read/Write. The latter is more error-prone.

Read and Write are just for writing to the gh file.

I implemented the SetValue and GetValue methods. They only save the values in the component, after I saved the GH file and re-open it the GetValue did not work. so I think I go with Dani’s solution.
Thanks