RhinoCommon/Grasshopper: A New Class for Geometry with Key/Value Pairs? UserData? - Grasshopper2024-03-29T13:46:29Zhttps://www.grasshopper3d.com/forum/topics/rhinocommongrasshopper-a-new?feed=yes&xn_auth=nowould it be possible to seria…tag:www.grasshopper3d.com,2013-03-04:2985220:Comment:8013172013-03-04T11:53:57.008Zmichael sprinzlhttps://www.grasshopper3d.com/profile/Sprinzl
<p>would it be possible to serialize a System.Object?</p>
<p>would it be possible to serialize a System.Object?</p> thanks Florian. i thought I…tag:www.grasshopper3d.com,2013-02-27:2985220:Comment:7979522013-02-27T16:39:35.305ZBenjamin Golderhttps://www.grasshopper3d.com/profile/BenjaminGolder
<p> thanks Florian. i thought I might be getting a tuple with a boolean value in front, but if I assigned the output to two variables, it couldn't unpack the tuple.</p>
<p>a, data = <span>my.UserDictionary.TryGetValue("key") # doesn't unpack</span></p>
<p>Anyways, thanks, I'll try some other approaches.</p>
<p> thanks Florian. i thought I might be getting a tuple with a boolean value in front, but if I assigned the output to two variables, it couldn't unpack the tuple.</p>
<p>a, data = <span>my.UserDictionary.TryGetValue("key") # doesn't unpack</span></p>
<p>Anyways, thanks, I'll try some other approaches.</p> Hi Benjamin,
I'm working with…tag:www.grasshopper3d.com,2013-02-26:2985220:Comment:7971812013-02-26T22:34:45.976ZFlorian Frankhttps://www.grasshopper3d.com/profile/FlorianFrank
<p>Hi Benjamin,</p>
<p>I'm working with the UserDictionary for a while now and it's working properly. Since i'm working in C# i think it might be a problem with the DataType functionality in Python. </p>
<p>In Python if you read the value of that entry in the ArchivableDictionary (type of UserDictionary) you'll get a tuple...so your BaseGeometry value should be there...try this ...for me it works:</p>
<p> </p>
<pre><code> import Rhino.Geometry as g<br></br> import rhinoscriptsyntax as rs<br></br> my =…</code></pre>
<p>Hi Benjamin,</p>
<p>I'm working with the UserDictionary for a while now and it's working properly. Since i'm working in C# i think it might be a problem with the DataType functionality in Python. </p>
<p>In Python if you read the value of that entry in the ArchivableDictionary (type of UserDictionary) you'll get a tuple...so your BaseGeometry value should be there...try this ...for me it works:</p>
<p> </p>
<pre><code> import Rhino.Geometry as g<br/> import rhinoscriptsyntax as rs<br/> my = g.LineCurve(g.Point3d(0,0,0),g.Point3d(0,0,1))<br/> other = g.LineCurve(g.Point3d(0,0,0), g.Point3d(0,0,2.64))<br/> my.UserDictionary.Set("key",other)<br/> data = my.UserDictionary.TryGetValue("key")<br/> print data[1].GetLength()</code></pre>
<p> </p>
<p>Cheers</p>
<p>FF</p> Hi Steve,
I'm updating a scr…tag:www.grasshopper3d.com,2013-02-26:2985220:Comment:7967972013-02-26T08:35:04.472ZBenjamin Golderhttps://www.grasshopper3d.com/profile/BenjaminGolder
<p>Hi Steve,</p>
<p></p>
<p>I'm updating a script that uses this feature, and I'm getting some strange behavior.</p>
<p>basically, I have a line like this, where I simply copy key value pairs of various data types into the UserDictionary of GeometryBase objects:</p>
<p></p>
<p>for k in data:<br></br> geom.UserDictionary.Set( k, data[k] )</p>
<p></p>
<p>I assume that the overloading of the Set method can handle the different data types, and determine the appropriate storage type. However, when I…</p>
<p>Hi Steve,</p>
<p></p>
<p>I'm updating a script that uses this feature, and I'm getting some strange behavior.</p>
<p>basically, I have a line like this, where I simply copy key value pairs of various data types into the UserDictionary of GeometryBase objects:</p>
<p></p>
<p>for k in data:<br/> geom.UserDictionary.Set( k, data[k] )</p>
<p></p>
<p>I assume that the overloading of the Set method can handle the different data types, and determine the appropriate storage type. However, when I set a variety of keys in this manner, and later try to access them, they have all become Boolean values, irrelevant of their previous type. Perhaps they were being cast to the first method overload? Set( key, Bool)?</p>
<p></p> That's great news!
I suppos…tag:www.grasshopper3d.com,2011-05-26:2985220:Comment:2521972011-05-26T17:51:34.424ZBenjamin Golderhttps://www.grasshopper3d.com/profile/BenjaminGolder
<p>That's great news!</p>
<p> </p>
<p>I suppose for the time being I can just make a wrapper class with UserString and Geometry attributes when I have a need for this functionality.</p>
<p>That's great news!</p>
<p> </p>
<p>I suppose for the time being I can just make a wrapper class with UserString and Geometry attributes when I have a need for this functionality.</p> Hi Ben,
This is something I p…tag:www.grasshopper3d.com,2011-05-25:2985220:Comment:2510122011-05-25T05:41:44.521ZSteve Baerhttps://www.grasshopper3d.com/profile/SteveBaer
<p>Hi Ben,</p>
<p>This is something I plan on implementing in RhinoCommon. I was thinking about adding a user dictionary to the geometry/attribute classes most likely in the form of the SerializableDictionary class</p>
<p><a href="http://www.rhino3d.com/5/rhinocommon/html/AllMembers_T_Rhino_Collections_ArchivableDictionary.htm" target="_blank">http://www.rhino3d.com/5/rhinocommon/html/AllMembers_T_Rhino_Collections_ArchivableDictionary.htm</a></p>
<p>I can always add support for more data types…</p>
<p>Hi Ben,</p>
<p>This is something I plan on implementing in RhinoCommon. I was thinking about adding a user dictionary to the geometry/attribute classes most likely in the form of the SerializableDictionary class</p>
<p><a href="http://www.rhino3d.com/5/rhinocommon/html/AllMembers_T_Rhino_Collections_ArchivableDictionary.htm" target="_blank">http://www.rhino3d.com/5/rhinocommon/html/AllMembers_T_Rhino_Collections_ArchivableDictionary.htm</a></p>
<p>I can always add support for more data types to this class.</p>
<p>-Steve</p> another related Discussion:
h…tag:www.grasshopper3d.com,2011-05-25:2985220:Comment:2508112011-05-25T01:19:19.768ZBenjamin Golderhttps://www.grasshopper3d.com/profile/BenjaminGolder
<p>another related Discussion:</p>
<p><a href="http://www.grasshopper3d.com/forum/topics/rhinocommon-can-we-have-a" target="_blank">http://www.grasshopper3d.com/forum/topics/rhinocommon-can-we-have-a</a></p>
<p>In which David makes a good point about the problems of implementing UserData. So is the solution to simply separate userData from Geometry for Grasshopper? I feel like there must be some solution that would solve most of the desired use cases but which could bypass most of the problems…</p>
<p>another related Discussion:</p>
<p><a href="http://www.grasshopper3d.com/forum/topics/rhinocommon-can-we-have-a" target="_blank">http://www.grasshopper3d.com/forum/topics/rhinocommon-can-we-have-a</a></p>
<p>In which David makes a good point about the problems of implementing UserData. So is the solution to simply separate userData from Geometry for Grasshopper? I feel like there must be some solution that would solve most of the desired use cases but which could bypass most of the problems described by David.</p>