GH_ObjectWrapper into text panel


#1

Hi,

Is there any way to set a custom text when a GH_ObjectWrapper / a custom data type is converted to string into a text panel? Right now it only prints the data type contained into the wrapper.

I have already overriden the method ToString : it gives a nice description when going over the Data Parameter component, but this is not the one used by the Text Panel.

Thanks!


(David Rutten) #2

Nope, if you want to control how your data is formatted, you must provide an actual implementation of IGH_Goo. GH_ObjectWrapper is a last-ditch attempt to make data flow through wires, but ideally you should not have to rely on it.


#3

Ok, thanks for the quick reply David, I will go for a custom IGH_Goo implementation then.


#4

Quick question @DavidRutten, I did it the way you suggested by getting rig of the GH_ObjectWrapper, it’s working like a charm.

But, when I implemented the IGH_Goo.ToString Method from the interface, it didn’t change the text displayed into the Panel, I had to override the ToString method inherited from System.Object. What the point of the Interface Function then? Is there something I don’t get about the difference between the two?

There is no urgent answer needed, I am just feeling a bit confused.


(David Rutten) #5

I am too now, but I suspect it’s there to provide the ToString under certain type constraint contexts. I’d say just have on ToString method call the other if they are separate methods at all in your code.