public override bool Read(GH_IO.Serialization.GH_IReader reader) { // 2013 Oct 8 - Giulio // Removing all hacks and making this work properly from Gh 0.9.61 onwards // The logic is this: this component ALWAYS gets constructed without "code" & with "out". // Then, when they are not necessary, these are added or removed. // RegisterInput/Output must always insert the original amount of items. if (reader.ItemExists(ID_EditorLocation)) DefaultEditorLocation = reader.GetDrawingPoint(ID_EditorLocation); if (reader.ItemExists(ID_EditorSize)) DefaultEditorSize = reader.GetDrawingSize(ID_EditorSize); bool hideInput = true; if (reader.TryGetBoolean(ID_HideInput, ref hideInput)) HiddenCodeInput = hideInput; bool hideOutput = false; if (reader.TryGetBoolean(ID_HideOutput, ref hideOutput)) HiddenOutOutput = hideOutput; if (hideInput) if (!reader.TryGetString(ID_CodeInput, ref m_inner_codeInput)) m_inner_codeInput = string.Empty; bool rc = base.Read(reader); // Dynamic input fix for existing scripts // Always assign DynamicHint or Grasshopper // will set Line and not LineCurve, etc... if (Params != null && Params.Input != null) { for (int i = HiddenCodeInput ? 1 : 0; i < Params.Input.Count; i++) { var p = Params.Input[i] as Param_ScriptVariable; if (p != null) { FixGhInput(p, false); if (p.TypeHint == null) { p.TypeHint = p.Hints[0]; } } } } return rc; }
public override bool Read(GH_IO.Serialization.GH_IReader reader) { // First read our own field. if (reader.ItemExists("ComponentName")) { this.customNameSet = true; this.ComponentName = reader.GetString("ComponentName"); } // Then call the base class implementation. return base.Read(reader); }