GH: Reading param info from ScriptComponents

Q1: I’m trying to figure out how a paramater in the signature of GH Script Components (VB,NET & C#.NET) is defined as a reference (ref) or by value, but it seems I cannot from the massive info below figure out which of the properties holds this info.

Q2: I would also like to know how to determine (again, from the info below) how a paramater is defoined as an out parameter.

foreach (int i=0; i< comp.Params.Input.Count; i++) 
      IGH_Param param = comp.Params.Input[i];
      param.HuhProperty?  // which one defines ref, 'by value' or 'out' ?

Q3: I also failed to find where the visibility for the signature is defined (perhaps not really need in a ScriptComponent since the signature is fixed, but it would be nice to know anyway). How/where?

The following Watch properties were copied during a debug session:

comp.				{ScriptComponents.Component_VBNET_Script}	Grasshopper.Kernel.IGH_DocumentObject {ScriptComponents.Component_VBNET_Script}
	Attributes			{ScriptComponents.GenericScriptAttributes}	Grasshopper.Kernel.IGH_Attributes {ScriptComponents.GenericScriptAttributes}
	AvailableTypeHints		Count = 29	System.Collections.Generic.List<Grasshopper.Kernel.Parameters.IGH_TypeHint>
	Category				"Maths"	string
	ClippingBox			{1,0,0 - -1,0,0}	Rhino.Geometry.BoundingBox
	ComponentGuid			{079bd9bd-54a0-41d4-98af-db999015f63d}	System.Guid
	DataComparison		LongestList	Grasshopper.Kernel.GH_DataComparison
	Description			"A VB.NET scriptable component"	string
	Exposure				secondary	Grasshopper.Kernel.GH_Exposure
	HasCategory			true	bool
	HasSubCategory		true	bool
	HelpDescription			"A VB.NET scriptable component"	string
	Hidden				false	bool
	Icon					{System.Drawing.Bitmap}	System.Drawing.Bitmap
	IconCapableUI			true	bool
	IconDisplayMode		application	Grasshopper.Kernel.GH_IconDisplayMode
	Icon_24x24			{System.Drawing.Bitmap}	System.Drawing.Bitmap
	Icon_24x24_Locked		{System.Drawing.Bitmap}	System.Drawing.Bitmap
	InConstructor			false	bool
	InstanceDescription		"This component ran once.\r\n"	string
	InstanceGuid			{225cbc84-4af4-4cd4-9f24-4e25ab9c5e63}	System.Guid
	Internal_Icon_24x24		null	System.Drawing.Bitmap
	IsBakeCapable			false	bool
	IsDataProvider			false	bool
	IsPreviewCapable		true	bool
	IsValidPrincipalParameterIndex			false	bool
	Keywords				null	System.Collections.Generic.IEnumerable<string>
	Language				VB	Grasshopper.GUI.Script.GH_ScriptLanguage
	Locked				false	bool
	Message				null	string
	MutableNickName		true	bool
	Name				"VB Script"	string
	NickName				"VB"	string
	Obsolete				false	bool
	Params				{Grasshopper.Kernel.GH_ComponentParamServer}	Grasshopper.Kernel.GH_ComponentParamServer
	*	Input					Count = 2	System.Collections.Generic.List<Grasshopper.Kernel.IGH_Param>
	*		[0]					{Grasshopper.Kernel.Parameters.Param_ScriptVariable}	Grasshopper.Kernel.IGH_Param {Grasshopper.Kernel.Parameters.Param_ScriptVariable}
				Access			item	Grasshopper.Kernel.GH_ParamAccess
				AllowTreeAccess	true	bool
				AngleParameter		false	bool
				Attributes			{Grasshopper.Kernel.Attributes.GH_LinkedParamAttributes}	Grasshopper.Kernel.IGH_Attributes {Grasshopper.Kernel.Attributes.GH_LinkedParamAttributes}
				Category			"Maths"	string
				ClippingBox		{1,0,0 - -1,0,0}	Rhino.Geometry.BoundingBox
				ComponentGuid		{84fa917c-1ed8-4db3-8be1-7bdc4a6495a2}	System.Guid
				DataMapping		None	Grasshopper.Kernel.GH_DataMapping
				DataType			void	Grasshopper.Kernel.GH_ParamData
				Description		"Script Variable x"	string
				Exposure			-1	Grasshopper.Kernel.GH_Exposure
				HasCategory		true	bool
				HasProxySources	false	bool
				HasSubCategory	true	bool
				Hidden			false	bool
				Hints				Count = 29	System.Collections.Generic.List<Grasshopper.Kernel.Parameters.IGH_TypeHint>
				Icon				{System.Drawing.Bitmap}	System.Drawing.Bitmap
				IconCapableUI		true	bool
				IconDisplayMode	application	Grasshopper.Kernel.GH_IconDisplayMode
				Icon_24x24		{System.Drawing.Bitmap}	System.Drawing.Bitmap
				Icon_24x24_Locked	{System.Drawing.Bitmap}	System.Drawing.Bitmap
				InstanceDescription	"{Type hint: Point3d}\r\nEmpty Generic Data parameter"	string
				InstanceGuid		{9cddcad6-66f3-4da5-bd56-95c5d44c58db}	System.Guid
				Internal_Icon_24x24	null	System.Drawing.Bitmap
				IsBakeCapable		false	bool
				IsDataProvider		false	bool
				IsPreviewCapable	true	bool
				IsPrincipal			IsNotPrincipal	Grasshopper.Kernel.GH_PrincipalState
				Keywords			null	System.Collections.Generic.IEnumerable<string>
				Kind				input	Grasshopper.Kernel.GH_ParamKind
				Locked			false	bool
				MutableNickName	true	bool
				Name			"x"	string
			*	NickName			"XX"	string
				Obsolete			false	bool
				Optional			true	bool
				PersistentData		{empty structure}	Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.IGH_Goo>
				PersistentDataCount	0	int
				Phase			Collected	Grasshopper.Kernel.GH_SolutionPhase
				ProcessorTime		{00:00:00.0000012}	System.TimeSpan
				ProxySourceCount	0	int
				Recipients			Count = 0	System.Collections.Generic.IList<Grasshopper.Kernel.IGH_Param> {System.Collections.Generic.List<Grasshopper.Kernel.IGH_Param>}
				Reverse			false	bool
				RuntimeMessageLevel	Blank	Grasshopper.Kernel.GH_RuntimeMessageLevel
				ShowHints			true	bool
				Simplify			false	bool
				SourceCount		0	int
				Sources			Count = 0	System.Collections.Generic.IList<Grasshopper.Kernel.IGH_Param> {System.Collections.Generic.List<Grasshopper.Kernel.IGH_Param>}
				StateTags			Count = 0	Grasshopper.Kernel.GH_StateTagList
				SubCategory		"Script"	string
			*	Type				{Name = "IGH_Goo" FullName = "Grasshopper.Kernel.Types.IGH_Goo"}	System.Type {System.RuntimeType}
			*	TypeHint			{Grasshopper.Kernel.Parameters.Hints.GH_Point3dHint}	Grasshopper.Kernel.Parameters.IGH_TypeHint {Grasshopper.Kernel.Parameters.Hints.GH_Point3dHint}
					HintID			{e1937b56-b1da-4c12-8bd8-e34ee81746ef}	System.Guid
			*		TypeName			"Point3d"	string
				TypeName			"Generic Data"	string
				UseDegrees		false	bool
				VolatileData		{empty structure}	Grasshopper.Kernel.Data.IGH_Structure {Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.IGH_Goo>}
				VolatileDataCount	0	int
				WireDisplay		default	Grasshopper.Kernel.GH_ParamWireDisplay

// Rolf

The question makes no sense. Although the word “parameter” is used both to describe the data containers in Grasshopper and the elements passed to a method invoke, they are not the same thing.

In C#, method parameters can be decorated with either ref or out keywords. In VB.NET you only get the ByRef keyword, and you have to add an attribute if you want to imply out-ness as well. The .NET Intermediate Language only really has support for ref type parameters. out is used only by C# to throw compiler errors in order to reduce the chances of a mistake in the code.

Parameters in Grasshopper (or types that implement IGH_Param to be totally specific) are fairly complicated types that can exist as free-floating entities or as component inputs/outputs. The main functionality of an IGH_Param type is to maintain a GH_Structure<T> data tree which is populated during solutions. Furthermore most parameter types are able to perform some modifications on the data tree such as flattening, grafting, applying expressions, etc.

The reason both these things are called ‘parameters’ is because in a way a Grasshopper component can be seen as a method, and the inputs/outputs as the method signature. It is a metaphor, nothing more.

Well, I think it made sense. At least for the fixed main method signatures of script components since “fixed” applies only to the immutable method signatures of, well, the script components. I’m talking about the first signature shown when opening a script component in GH. Examples:

  Private Sub RunScript(ByVal G As GeometryBase, ByVal t As List(Of Double), ByVal clr As List(Of Color), ByRef A As Object) 
	'   --[G     A]--
	'   --[t      ]
	'   --[clr    ]
  End Sub

  private void RunScript(object x, object y, ref object A, ref object B)
	//  --[x     A]--
	//  --[y     B]--

Anyway, I’m making a GH component for dumping the code content to disk from C# & VB,NET script components (useful for version control etc) plus the signatures for the main method (increases readability of the dumped code if dumping also the signature).

This main method signature info of the script components can be retrieved from the (ScriptComponent) .Params.Input & Output properties as shown in my original post (and so any meaningful answer would point out which of the posted properties I should regard).

  IGH_Param param = "ScriptComponent".Params.Input[i];


  IGH_Param param = "ScriptComponent".Params.Output[i];

The dumped Watch variable data structure in the original post was taken from the level of Input[0] as shown above. According to the posted data structure this Input[] data is of the following type: “{Grasshopper.Kernel.Parameters.Param_ScriptVariable}”, and so on.

Although I do appreciate your informative extensive answers it didn’t actually address any of my questions.

// Rolf

Well, all the parameters that appear in the GH_Component.Params.Input list come first and without a ref keyword in the signature, all parameters that appear in the GH_Component.Params.Output list come second and with a ref keyword. The outputs have to be assigned by the script, so obviously they need a ref keyword. I thought this was not what you were asking since you already seem to have said as much yourself. So I really don’t understand the question then.

If this is always so, a rule that is, then you have answered my question.

Only if assuming that I already know the answer, which you just gave (namely that the rule is that it’s always and exactly so), and therefore the “ref” keyword (or no ref keyword) on outputs and inputs respectively is not explicitly recorded, only then there’s no meaningful question asked.

But I tend to avoid asking for answers which I already know that answer to. Because that would makes no sense.

No, I do not think this is funny.

// Rolf

I apologise for being glib about this. I thought the answer you seemed to be looking for was so obvious that it could not possibly be the answer you were after. I was wrong.

Apology accepted. No hard feelings.

// Rolf