Loaded assets look like numbers but are a different type

Hi @mostapha,

I’ve noticed that some of the downloaded outputs look like numbers but are some other type, which means I need to run them through a Number parameter component first. Is there a reason for this?

Grasshopper’s native Average component throws an error but the native Multiply component doesn’t, so I didn’t notice at first that I was getting the wrong results:

Technically it should show up as numbers. I checked the handler that loads the results and it converts them to numbers:

@mingbo, is this the behavior of the Grasshopper component to change the type to text if it doesn’t know the type? Or does it use the type of the output alias?

@chris, can you confirm that I’m checking the correct function for parsing the results?

I can confirm here I can recrate this issue.
It is because I used a generic GH_ObjectWrapper for all output data for constructing the GH_DataTree, instead of trying to guess what each of the real types are.

I will try to find a better solution here.

2 Likes

I know I’m incredibly late here but I thought it was still worth confirming that @mostapha has found the correct handler function there. The issue is in regards to the GH_ObjectWrapper that is being used. In case it’s helpful, @mingbo , this is how we construct the DataTree in IronPython:

I think we get away with using the s_type=object in IronPython because GHPython does type-checking on everything that is output from the component. On the C# end, if you were to use a different s_type when constructing the data tree, I think you can get everything imported as a float instead of the generic object type.