Extract component Nickname and values

Hi there!
I have a script where I need to collect name and color (Situation A).
I’m trying to simplify the amount of components in the script and therefore combine the name and color together in one component. I have a Python code that already gives me the component Nickname (name) but can’t figure out how to extract the component value (color) (Situation B).
If possible, even better would be to be able to extract those two values at a later stage, by allowing the Python to extract the nickName and values at above the top level, so the Python could be hidden inside a cluster (Situation C).

If possible any help with this, or some direction where to find the info, I would be very appreciated.
I’m only now entering in the Python world :slight_smile:

Jota


Extract component Nickname and values.gh (10.6 KB)

Hi Jsguima
You can use the SwatchColour attribute.


Extract component Nickname and values.gh (13.7 KB)

1 Like

Thank you very much Naruto for the prompt help!!! :handshake:
Exactly what I was asking for in situation B!

To achieve the situation C, I was trying to dig a bit more in the forum but only stumble upon C# scripts and I’m also not able to make them work:
https://discourse.mcneel.com/t/find-inputs-of-a-component-and-managing-its-data/64943/11
Top Level Attributes

Ideally the Python component is hidden inside the cluster and from outside, we only have to plugin the swatch color component directly into the cluster.
Therefore it would be needed to collect those attributes from a level above (I assume called topLevel).
I give here a more precise image and gh file with what is my intention, if anyone can help with:


Extract top level attributes.gh (3.8 KB)

Thank you once more for the help!!!

try this:


Extract top level attributes.gh (6.0 KB)

Thank you Naruto for once more giving such prompt help!

Indeed it works well with this Python component to get the top level attributes, but unfortunately, once it is placed inside a cluster it doesn’t recognize what is coming out of the cluster.
I found this topic where it seems, it is hard to get the data this way out of a cluster.

So perhaps I need to rethink my original solution:

I have a cluster with several inputs and where “building program” and respective colors are just some of them (A).
In order to simplify the cluster from the outside and reduce the number of input slots, I was trying to combine both data (program+color) in one single component and input slot (B). This would also guarantee that there was no mistake to which program does each color belongs. But can’t find a component that can do that (combine two in one).


Simplify inputs.gh (8.9 KB)

Any suggestions are welcomed!
I’ll keep searching for a solution and will update if I find anything :slight_smile: