/// <summary> /// Registers all the output parameters for this component. /// </summary> protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) { NicknameConverter nC = new NicknameConverter(); IList <PropertyInfo> outputs = ActionBase.ExtractOutputParameters(ActionType); foreach (PropertyInfo pInfo in outputs) { Type pType = pInfo.PropertyType; ActionOutputAttribute outputAtt = ActionOutputAttribute.ExtractFrom(pInfo); if (outputAtt != null) { string name = pInfo.Name; string nickname = string.IsNullOrEmpty(outputAtt.ShortName) ? nC.Convert(pInfo.Name) : outputAtt.ShortName; string description = outputAtt.CapitalisedDescription; if (pType == typeof(double) || pType == typeof(Angle)) { pManager.AddNumberParameter(name, nickname, description, GH_ParamAccess.item); } else if (pType == typeof(int)) { pManager.AddIntegerParameter(name, nickname, description, GH_ParamAccess.item); } else if (pType == typeof(string)) { pManager.AddTextParameter(name, nickname, description, GH_ParamAccess.item); } else if (pType == typeof(bool)) { pManager.AddBooleanParameter(name, nickname, description, GH_ParamAccess.item); } else if (pType == typeof(Vector)) { pManager.AddPointParameter(name, nickname, description, GH_ParamAccess.item); } else if (pType.IsAssignableFrom(typeof(Plane))) { pManager.AddPlaneParameter(name, nickname, description, GH_ParamAccess.item); } else if (typeof(Curve).IsAssignableFrom(pType)) { pManager.AddCurveParameter(name, nickname, description, GH_ParamAccess.item); } else if (typeof(CurveCollection).IsAssignableFrom(pType)) { pManager.AddCurveParameter(name, nickname, description, GH_ParamAccess.list); } else if (pType == typeof(LinearElement)) { IGH_Param param = new LinearElementParam(); pManager.AddParameter(param, name, nickname, description, GH_ParamAccess.item); } else if (pType == typeof(LinearElementCollection)) { IGH_Param param = new LinearElementParam(); pManager.AddParameter(param, name, nickname, description, GH_ParamAccess.list); } else if (pType == typeof(Element)) { IGH_Param param = new ElementParam(); pManager.AddParameter(param, name, nickname, description, GH_ParamAccess.item); } else if (pType == typeof(ElementCollection)) { IGH_Param param = new ElementParam(); pManager.AddParameter(param, name, nickname, description, GH_ParamAccess.list); } else if (pType == typeof(Node)) { IGH_Param param = new NodeParam(); pManager.AddParameter(param, name, nickname, description, GH_ParamAccess.item); } else if (pType == typeof(NodeCollection)) { IGH_Param param = new NodeParam(); pManager.AddParameter(param, name, nickname, description, GH_ParamAccess.list); } else if (typeof(Nucleus.Model.Material).IsAssignableFrom(pType)) { IGH_Param param = new MaterialParam(); pManager.AddParameter(param, name, nickname, description, GH_ParamAccess.item); } else if (typeof(MaterialCollection).IsAssignableFrom(pType)) { IGH_Param param = new MaterialParam(); pManager.AddParameter(param, name, nickname, description, GH_ParamAccess.list); } else if (typeof(SectionFamily).IsAssignableFrom(pType)) { IGH_Param param = new SectionFamilyParam(); pManager.AddParameter(param, name, nickname, description, GH_ParamAccess.item); } else if (pType == typeof(Bool6D)) { IGH_Param param = new Bool6DParam(); pManager.AddParameter(param, name, nickname, description, GH_ParamAccess.item); } else if (pType == typeof(VertexGeometry)) { pManager.AddGeometryParameter(name, nickname, description, GH_ParamAccess.item); } else if (pType == typeof(VertexGeometryCollection)) { pManager.AddGeometryParameter(name, nickname, description, GH_ParamAccess.list); } else { pManager.AddGenericParameter(pInfo.Name, nC.Convert(pInfo.Name), outputAtt.CapitalisedDescription, GH_ParamAccess.item); } //TODO } } }
/// <summary> /// Registers all the input parameters for this component. /// </summary> protected override void RegisterInputParams(GH_InputParamManager pManager) { IAction action = (IAction)Activator.CreateInstance(ActionType, true); NicknameConverter nC = new NicknameConverter(); IList <PropertyInfo> inputs = ActionBase.ExtractInputParameters(ActionType); foreach (PropertyInfo pInfo in inputs) { Type pType = pInfo.PropertyType; ActionInputAttribute inputAtt = ActionInputAttribute.ExtractFrom(pInfo); if (inputAtt != null && inputAtt.Parametric) { string name = pInfo.Name; string nickname = string.IsNullOrEmpty(inputAtt.ShortName) ? nC.Convert(pInfo.Name) : inputAtt.ShortName; string description = inputAtt.CapitalisedDescription; if (pType == typeof(double)) { pManager.AddNumberParameter(name, nickname, description, GH_ParamAccess.item, (double)pInfo.GetValue(action, null)); } else if (pType == typeof(int)) { pManager.AddIntegerParameter(name, nickname, description, GH_ParamAccess.item, (int)pInfo.GetValue(action, null)); } else if (pType == typeof(string)) { pManager.AddTextParameter(name, nickname, description, GH_ParamAccess.item, (string)pInfo.GetValue(action, null)); } else if (pType == typeof(bool)) { //Special case when the input is a 'Write' toggle - default off! pManager.AddBooleanParameter(name, nickname, description, GH_ParamAccess.item, name == "Write" ? false : (bool)pInfo.GetValue(action, null)); } else if (pType == typeof(Vector)) { pManager.AddPointParameter(name, nickname, description, GH_ParamAccess.item); } else if (typeof(IList <Vector>).IsAssignableFrom(pType)) //Vector list { pManager.AddPointParameter(name, nickname, description, GH_ParamAccess.list); } else if (pType.IsAssignableFrom(typeof(Plane))) { pManager.AddPlaneParameter(name, nickname, description, GH_ParamAccess.item, ToRC.Convert((Plane)pInfo.GetValue(action, null))); } else if (pType == typeof(Line)) { pManager.AddLineParameter(name, nickname, description, GH_ParamAccess.item); } else if (pType == typeof(Angle)) { pManager.AddAngleParameter(name, nickname, description, GH_ParamAccess.item, (Angle)pInfo.GetValue(action, null)); } else if (typeof(Curve).IsAssignableFrom(pType)) { pManager.AddCurveParameter(name, nickname, description, GH_ParamAccess.item); } else if (typeof(CurveCollection).IsAssignableFrom(pType)) { pManager.AddCurveParameter(name, nickname, description, GH_ParamAccess.list); } else if (typeof(LinearElement).IsAssignableFrom(pType)) { IGH_Param param = new LinearElementParam(); pManager.AddParameter(param, name, nickname, description, GH_ParamAccess.item); } else if (typeof(PanelElement).IsAssignableFrom(pType)) { IGH_Param param = new PanelElementParam(); pManager.AddParameter(param, name, nickname, description, GH_ParamAccess.item); } else if (typeof(Element).IsAssignableFrom(pType)) { IGH_Param param = new ElementParam(); pManager.AddParameter(param, name, nickname, description, GH_ParamAccess.item); } else if (typeof(LinearElementCollection).IsAssignableFrom(pType)) { IGH_Param param = new LinearElementParam(); pManager.AddParameter(param, name, nickname, description, ParamAccess(inputAtt)); } else if (typeof(PanelElementCollection).IsAssignableFrom(pType)) { IGH_Param param = new PanelElementParam(); pManager.AddParameter(param, name, nickname, description, ParamAccess(inputAtt)); } else if (typeof(ElementCollection).IsAssignableFrom(pType)) { IGH_Param param = new ElementParam(); pManager.AddParameter(param, name, nickname, description, ParamAccess(inputAtt)); } else if (pType == typeof(Node)) { IGH_Param param = new NodeParam(); pManager.AddParameter(param, name, nickname, description, GH_ParamAccess.item); } else if (pType == typeof(NodeCollection)) { IGH_Param param = new NodeParam(); pManager.AddParameter(param, name, nickname, description, ParamAccess(inputAtt)); } else if (typeof(Nucleus.Model.Material).IsAssignableFrom(pType)) { IGH_Param param = new MaterialParam(); pManager.AddParameter(param, name, nickname, description, GH_ParamAccess.item); } else if (typeof(MaterialCollection).IsAssignableFrom(pType)) { IGH_Param param = new MaterialParam(); pManager.AddParameter(param, name, nickname, description, ParamAccess(inputAtt)); } else if (typeof(SectionFamily).IsAssignableFrom(pType)) { IGH_Param param = new SectionFamilyParam(); pManager.AddParameter(param, name, nickname, description, GH_ParamAccess.item); } else if (pType == typeof(Bool6D)) { IGH_Param param = new Bool6DParam(); pManager.AddParameter(param, name, nickname, description, GH_ParamAccess.item); } else if (pType == typeof(FilePath)) { pManager.AddTextParameter(name, nickname, description, GH_ParamAccess.item); } else if (pType == typeof(VertexGeometry)) { pManager.AddGeometryParameter(name, nickname, description, GH_ParamAccess.item); } else if (pType == typeof(VertexGeometryCollection)) { pManager.AddGeometryParameter(name, nickname, description, ParamAccess(inputAtt)); } else if (pType == typeof(ActionTriggerInput)) { pManager.AddGenericParameter(name, nickname, description, GH_ParamAccess.tree); } else if (pType == typeof(Direction)) { pManager.AddTextParameter(name, nickname, description, GH_ParamAccess.item, pInfo.GetValue(action, null)?.ToString()); } else if (pType == typeof(CoordinateSystemReference)) { pManager.AddTextParameter(name, nickname, description, GH_ParamAccess.item, pInfo.GetValue(action, null)?.ToString()); } else if (pType.IsEnum) { pManager.AddTextParameter(name, nickname, description, GH_ParamAccess.item, pInfo.GetValue(action, null)?.ToString()); } else { pManager.AddGenericParameter(pInfo.Name, nickname, description, GH_ParamAccess.item); } if (inputAtt.Required == false) { pManager[pManager.ParamCount - 1].Optional = true; } //TODO } } }