A question about custom component parameter type


(Andrealu2012) #1

i am programming with kuka robot,using kuka prc.
The problem is :When I retrive a item of kuka command from kuka robot command list by C# compnent,the result is different with the native component"retrive item from list".
as following:

C# component code :
private void RunScript(List<System.Object> x, ref object A)
A = x[0];

The hard point is KuKa command is from KuKa|PRC ,this parameter is customize,it is different with native data type…
how can i use C# component to get the same result?
Thank you!

(Keyu Gan) #2

It might be because of different behaviors of implicit conversion from IGH_Goo to ‘object’ (here).

I would recommend to use some technique to probe what are happening in the parameters. Try using Param info from Metahopper. Or a IL debugger :smile:


Difficult to say what happened here since I don’t have access to Kuka|prc, nor a Kuka robot :wink:

Script component actually does much more than your code. You will also be suprised when you read the implementation of List item component.

(David Rutten) #3

That would be my guess too. When data goes into a script component, the data type is allowed to convert itself into a ‘safe’ format. This means that from within a script component you cannot get the actual GH_Point, GH_Line, GH_Brep data, as they have already been converted into Rhino.Geometry.Point3d, Rhino.Geometry.Line and Rhino.Geometry.Brep respectively. Kuka may be doing a similar conversion.

If you really need the original data, you’re going to have to get it yourself from the inputs. But that means collecting the entire tree, so no more per-item calls to RunScript().

(Andrealu2012) #4

thank you,David and GankeYu,i have understand a littel.

(qythium) #5

My guess here is that the Kuka library defined a custom IGH_Goo wrapper for their underlying data type with an overridden ToString() method for pretty output.
See what happens if you plug the output of scripting component into one of those param components:


(Keyu Gan) #6

More info:

One of the param is GH_PRC_CommandData, which inherits GH_Goo<PRC_CommandData>, and the other is PRC_CommandData. The former one has a ToString overload. I think scripting component unwraps the GH_Goo automatically.

(Andrealu2012) #7

I try it,but failed…

(Keyu Gan) #8

Late answer. You can use Component.Param.Input to access the ‘raw’ version of parameter