Custom Component to Add Custom Attributes to Object

Hi, I would like to add custom attribute to objects on canvas and wonder if it is possible to do so.

So far, I have only tested below script by adding 1 panel component on the canvas except the custom component.

GH_DocumentIO docIO = new GH_DocumentIO(this.OnPingDocument());
foreach (IGH_DocumentObject obj in this.OnPingDocument().Objects)
            //for all objects except this custom component
            if (obj.InstanceGuid != this.InstanceGuid)
                   obj.Attributes = (Grasshopper.Kernel.IGH_Attributes) "customAttributes"; // doesn't work because string cannot be converted

Printing obj.Attributes resulted in Grasshopper.Kernel.Special.GH_PanelAttributes. Should I use CreateAttributes() ? But I wonder if this is not the correct Object Properties to attach custom data/attributes.

Thank you

You can choose custom attributes for your own objects, but trying to override the attributes of existing objects is going to be a painful road, which will at the very least end in tears and probably in failure too.

1 Like