Closed daviddekoning closed 4 years ago
btw, I am hoping to have a colleague give the GH client some love shortly. I am flagging this here to see if this is a big issue for anyone else.
Thanks @daviddekoning ,
This will be greatly improved in 2.0. In the meantime you can use the normal "Set User Data" component. And please make sure your colleague joins the insider program so we can coordinate re GH client development :)
The fundamental issue here is the mismatch between this line:
and this line:
There are three possible solutions:
Dictionary
ArchivableDictionary
and convert it to a Dictionary
properties
property is an IDictionary.1 and 3 touch have a higher chance of a affecting other items.
@psarras any thoughts?
This is fixed in #311.
I followed a slightly modified version of item 2 above. Instead of only accepting an ArchivableDictionary
, the component now accepts any class that implements the IDictionary
interface, and converts it to a Dictionary
.
In addition, if the SpeckleObject to which the data is being attached already has custom user data, the component now adds the new data, instead of throwing out all the old properties and replacing them by the new ones. If a user data key exists in the both the old and the new user data, the new data overrights the old (on a key by key basis).
Step 0:
Expected Behaviour
Creating custom user data, then adding that to a Speckle Object should not give an error.
Actual Behaviour
The
Create Custom User Data
component is producing anArchivableDictionary
, and theSet User Data Speckle Object
is trying to cast it toDictionary
.Affected Projects
I believe that this is limited to GH.
Reproduction Steps & System Config (win, osx, web, etc.)
Proposed Solution (if any)
Perhaps this can be fixed by casting to
IDictionary
instead ofDictionary
here: https://github.com/speckleworks/SpeckleRhino/blob/af0fc2b79fd8bcc043ad54390dc2621097efcf2f/SpeckleGrasshopper/UserDataUtils/SetUserDataSpeckleObjectComponent.cs#L61.(It appears that this behaviour was changed in 9896f027202c4154426b87a5916da9f88dff9f9d).
The workaround is to attach data to object before converting them to Speckle Objects.