How to expose user input parameters outisde SolveInstance(IGH_DataAccess DA) in C#


I am currently developing a custom C# component (with user parameters calling GH_Component.GH_InputParamManager) and I want to Export (outside of Gh/Rh) some of the user defined input (item or list). However when I place my Export() method, inside SolveInstance() it gets executed each time user makes a change in the Grasshopper interface -which is not ideal.

I realize that the data access is limited to SolveInstance(), and it is a protectd class. Is there a way to expose some of the input parameters outside the SolveInstance() method so that they can be used in the my Export() method?

I have looked at:

I tried using GH_DocumentObject.OnPingDocument Method, but it still cannot access the user input parameters (item or list), help is greatly appreciated :slight_smile:

Thank you!

You do not need IGH_DataAccess to read the inputs, but you must do it in a context synchronized with the components protocol (i.e. after GH has called CollectData() or ComputeData(), where the inputs update their state). If your Export() method is called from the component menu, then (I think) this synchronization can be taken for granted. You need to loop the inputs, and read the VolatileData of each source parameter or the PersistenData of each component parameter if it has internalised values.

Hi @Dani_Abalde, thanks for your response, if I understand this correctly this would still take place inside the SolveInstance() method? Is there a way to pass on only some of the parameters once the solution is completed?

No, in your Export() method if it is called in a context after the component has been computed, e.g. from the component menu.