Using attributes as identifier in Grasshopper

One year after finishing working at Knippers-Helbig engineering office a question about Bengesht’s DivCCX component intrigued me to write about “Using attributes in Grasshopper to keep track of objects!”.

Working on the engineering of Metro Riyadh project (a grid structure), we had to deal with changing data structures and still keeping track of each element for the next operation. Using objects attributes or UserText to store their path was the solution.

This approach can be used with DivCCX (Divide Curves on Intersects) component of Bengesht. The problem is that this component operates over a flattened list of curves and the outcome is sorted arbitrarily. However, the outcome segments inherit their attributes from their original curve; meaning that any kind of identifier can be attached to the input curves and used later to distinguish the output ones.

Here I showed this technique by 1)putting each curve in a tree branch 2)attaching branch’s address to each curve 3)flattening tree structure 4)running division operation 5)putting back the split segments into their previous data structure.

Download Solution

I coded step 2 and 5 using GhPython. The function for adding these attributes is SetUserText and GetUserText.