Deserialization of custom Speckle objects from grasshopper source to python

Hello community,

I have trouble transferring data between grasshopper and python for a list of Base objects. In this case, we have a custom object defined in the speckle kit. As is shown below, the ‘demands’ is a list of Objects.BuiltElements.Revit.Parameters.
image

When we send it to speckle, it will be as shown below from datatree to base object.

Then we have registered the same class to the specklepy ‘_type_registry’, where we will have corresponding attributes for the Class defined in C#. This time, we will get an error as shown below.

The problem here is that the ‘demands’ should actually be a list of Parameters(Base), which is correctly defined in grasshopper as shown below. However, looks like it is converted to a Base object when sent from grasshopper to server, which will be considered the wrong type when imported into python. So I don’t if we should fix this in our own package, or do you think this is something worth attention in the specklepy package? Let us know :slight_smile:

1 Like

I think there’s a mismatch in the type definitions in c#/py.

From what is being dumped into speckle, it looks like this.demands is actually a base object in the c# class - you could redefine it as a list - which is what mr. python seems to want? I might be wrong - it’s difficult to tell without seeing the class definitions in both parts…

@dimitrie The python part is defined as below, the TypologyDemand is a subclass of Parameter defined in specklypy.
image

Let me know if you need more information.

Hm, i’d try to see if making the c# version of the Typology class have demands as a list and not as a Base object, and then just setting it in the constructor simply with this.demands = demands, without the ToBase() part.

1 Like

@dimitrie Nice, that is actually the problem, thanks! I think it works now

2 Likes