/*************************************/ /**** Public Methods ****/ /*************************************/ private static string ToText(ParamAdded update) { if (update != null) { return("Parameter " + update.Name + " added"); } else { return("Undefined param added"); } }
/*******************************************/ /**** Input Update Methods ****/ /*******************************************/ protected virtual void UpdateInput(ParamAdded update) { IGH_Param newParam = update.Param.ToGH_Param(); // If there is already a param with the same name, delete it but keep the wire connections // Same approach as `UpdateInput(ParamUpdated update)` but with index provided by ParamAdded IGH_Param match = Params.Input.Find(x => x.Name.ToLower() == update.Name.ToLower()); if (match != null) { MoveLinks(match, newParam); newParam.DataMapping = match.DataMapping; newParam.Simplify = match.Simplify; newParam.Reverse = match.Reverse; Params.UnregisterInputParameter(match); } Params.RegisterInputParam(newParam, update.Index); }
/*******************************************/ /**** Output Update Methods ****/ /*******************************************/ protected virtual void UpdateOutput(ParamAdded update) { IGH_Param newParam = update.Param.ToGH_Param(); // If there is already a param with the same name, delete it but keep the wire connections // Same approach as `UpdateOutput(ParamUpdated update)` but with index provided by ParamAdded IGH_Param match = Params.Output.Find(x => x.Name == update.Name); if (match != null) { newParam.NewInstanceGuid(match.InstanceGuid); newParam.DataMapping = match.DataMapping; newParam.Simplify = match.Simplify; newParam.Reverse = match.Reverse; match.Recipients.Clear(); Params.UnregisterOutputParameter(match); } Params.RegisterOutputParam(newParam, update.Index); }