protected override void RegisterInputParams(GH_InputParamManager pManager) { pManager.AddTextParameter("Text", "T", "Text content", GH_ParamAccess.item); pManager.AddTextParameter("Font", "F", "Text font", GH_ParamAccess.item); pManager.AddPointParameter("Location", "L", "Text location", GH_ParamAccess.item); pManager.AddColourParameter("Colour", "C", "Text colour", GH_ParamAccess.item, Color.Black); pManager.AddNumberParameter("Horizontal", "H", "Normalised horizontal offset", GH_ParamAccess.item, 0.0); pManager.AddNumberParameter("Vertical", "V", "Normalised vertical offset", GH_ParamAccess.item, 0.0); pManager.AddAngleParameter("Angle", "A", "Rotation angle.", GH_ParamAccess.item, 0.0); Param_Number angle = pManager[6] as Param_Number; if (angle != null) { angle.UseDegrees = true; } }
/// <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 } } }