Detect if component is disconnected from input param


Using BeforeSolveInstance() of a custom component, I am redefining the attributes of an input value lists. If a new value list is added to the input parameters, I am trying to avoid having to redefine already modified value lists. I am achieving this by keeping track of the InstanceGuid of input components through a HashSet. However, this logic, of course, breaks in the rare case of a value list being disconnected, modified (manually or through some other component) and then reconnected. Is there a way to identify GUIDs of components that are removed from input params or do I need to look for a better logic in implementing this?

Many thanks

there is a base.Params.ParameterSourcesChanged event

Ideally you’d hash the input data. What sort of types are you dealing with?

@DavidRutten @gankeyu Thank you both. Apologies for the late response here, haven’t had time to revisit this, until now. I was hoping to use this for two things, to create value lists for enum types and also installed fonts. I’ve attached a file that takes your suggestion into populating a value list with installed fonts. I’ve realized though that the approach to solving this problem is not so clean in general and Ideally, I’d have a custom value list component with my types ready to drop unto the GH canvas. I know you can do that by creating a user object from a modified value list component, but then that won’t be part of the gha assembly.

Based on this discussion the way to do that seems to inheret GH_Param<GH_Integer>, (and IGH_StateAwareObject? to make sure it doesn’t return to the default state when loading a gh file), am I on the right path here?

Many thanks.

fontValList.cs (1.6 KB)

Not needed for this particular problem, but always good to do if you want people easily return your object to a specific state.

This will involve writing (and reading) the current state into the GH file, which you do by overriding the Write() and Read() methods on your object.

For example imagine you have something like this:

public sealed class FontSelectorObject : GH_Param<GH_Integer>
  public int SelectedFontIndex { get; private set; }
  public override bool Write(GH_IWriter writer)
    writer.SetInt32("SelectedFontIndex", SelectedFontIndex);
    return base.Write(writer);
  public override bool Read(GH_IReader reader)
    SelectedFontIndex = reader.GetInt32("SelectedFontIndex");
    return base.Read(reader);

awesome Ill give that a try. appreciate the help!