GhPython - Passing Geometry with UserDictionary between components


#1

Hi, i cant figure out a way to pass from one python component to other one a instance of point class with user dictionary data. I´am experimenting a data loss (al least it seems so to me) when I output a list of point objects (point class) feed with keys and values in the UserDataDictionary. What am I missing?

thanks
aitor


#2


#3

oh, typehint for x is GeometryBase, but not sure if this the way to go… “noTypeHint” throws an error, as it seems that ghPython automatically converts the input to point3d, wich happens not to have a UserDictionary property…


(Giulio Piacentino) #4

Hi @aitorleceta,

Grasshopper.Kernel.Types.Gh_Point is based on Rhino.Geometry.Point3d and not on Rhino.Geometry.Point. Therefore, it cannot store and will discard the information that is passed to it via UserDictionary.

This was likely a design decision to make Grasshopper perform better with many points – a dictionary for each point is still heavy, after all.

If you want to pair the information, you could create your own AttributedPoint class and pass this information from one component to the other. However, I’d suggest to keep Grasshopper functionality intact and just pass two outputs in parallel.

Giulio

Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com