I have two sets of Breps which have exactly the same geometry (vertices positions), but the first set has some data (User Defined Dictionary values) I want to transfer to the second. I need a script or workflow which allows me to compare the two sets, and then copy the dictionary value from one to the other.
I know you can use DeBrep to get the Vertcies, and I could then compare these, but how do I then relate this back to the original Brep?
Still fairly new to all this so please assume I know almost nothing!
I’ve had a play with Elefront but not sure how it helps me with my problem. I want to compare two sets of Breps and where there is a match (in their geometry and position), to pass over an attribute (User Dictionary Key and Value). This is probably all pretty easy for someone with experience with Grasshopper!
See attached. There’s not much to show as I’m really not sure how to proceed. The geometry is 2 boxes that have been copied, with the copy placed on top of the original. This is to simulate having two sets of Breps with the same geometry (including location). My actual workflow will generate the second set of Breps by another route, but the outcome will be the same. Match Breps.3dm (31.8 KB)
If the vertices of the two items in the original set and copied set are identical, you do not need to compare all points. Instead you can simply find the closest point. Copy Attribute User Text from one set to an identical other set like this:
@martinsiegrist , thanks so much- this is brilliant, and has massively helped my general learning as well as the specific problem. A few questions for you:
The closest point is smart, but I guess it’s possible that two non-identical breps could have the same centroid?
With the Modify Rhino Object Attributes component, how does this know to overwrite the previous key and value, rather than adding a new one?
With my workflow it’s possible that the copied breps might be in a different order to the original. What would be a good way to reference to the new, perhaps with another user attribute? (which relates to 2)- this component overwrites rather than adds?
I think there is still an issue here, as some shapes can have both the same volume and the same centroid- a pipe, for example. I may need to explore some alternative approaches with Vertices. Thanks though- what I have now is working for 99% of cases.