NodeInCode List Item acts differently to actual List Item for custom data

Hi everyone,

We are having an issue while using a custom node (C#) that utilises NodeInCode. We have a node that is using “List Item” as a NodeInCode that is causing the error. When passing custom data types that are in goo wrappers through this they seem to be getting altered where as they do not when they are passed through an actual List Item component. It seems like it is just returning the value of the Goo and not the entire object. We’ve tested with with two different custom data types and get the same result for both. Has anyone experienced this or have an understanding what might be going on here?

Thanks in advance, Will

@dale do you have any experience with this that might be able to help us?

We’ve done some more testing with this and still no luck.

As shown here we’ve also tried passing a converted object but our result is still just the value of the underlying Goo after it passes through the List Item. It’s seeming like a bug rather than a mistake in our code at this point.

Still looking for answers if anyone has an idea!

Hi @William_Hamilton I’m looking into your code to see where the issue might be coming from… but do you really need the “node-in-code” solution if you’re simply just trying to do a List Item? Can’t you just get access to whatever index value from the incoming list? Alternatively, can you just use the existing List Item component to do what you need since it appears to be working the way you wanted?

@William_Hamilton After looking into this… I think the issue is that the Evaluate method is returning an array of generic type object. In your code, you’ve even declared your listItemResults as an object[]… however, this conversion is I think what is stripping the attribute metadata of your more specific class type. My suggestion would be to either use the existing List Item component to get the item your after, or declare your input with the type you’d like to pass in, and then select the item from that list using the standard list indexing method (ie. list[0]). Does this help?

Hi @AndyPayne,
Thanks for the answer.

As you said having the item we can loop through and solve the problem.
Even if we pass the data, not as an object[] the return result by a node in code is an object[] and it is where retains only the underline Goo.

Another thing we noticed, and maybe you could help as.
If we pass that Goo in any node performing a geometrical operation we will end up only having the geometry change without the data associated.
How do we keep the data after the geometry is updated? Do we need to perform a deep copy in the Goo?

Perhaps it would be easier to just use Rhinocommon instead of Node-in-code? Maybe just using the Rhinocommon methods will prevent you from having to cast as a generic object and you can simply retain the type and it’s attributes?

Regarding geometrical operation, I am talking about using the nodes not using nodes in code.
If we pass the Goo in a component move, we lost the attached data.

Ok. Sorry for the confusion. This is difficult to debug without a decent working example, etc. Can you apply your attributes at the end? Maybe you could explain more specifically what your end goal is and perhaps I could provide an alternative solution?

Yes of course. I’ll do that.