C# component updating

Hi there, is anyone able to help me. I am trying to update an old c# component that is expired in grasshopper. I created a new one and have copied the exact code but am still receiving an error saying ¨ERROR CS0246¨ applying to the following line of code:

static string Format(Color c)
{
return (new System.Text.StringBuilder(“A”)).Append(c.A.ToString()).Append(“R”).Append(c.R.ToString()).Append(“G”)
.Append(c.G.ToString()).Append(“B”).Append(c.B.ToString()).ToString();
}

i dont understand though as it is the exact same as the expired component.

Do you have any suggestions?

Can you attach something so others can replicate the error?

See attached

Color_Format.gh (4.1 KB)

PS: Avoid locomotive long expresions. And why a SB? string.Format() could cut the mustard.

Thank you for your reply! I cant seem to fix it though still… I have attached the code. Are you able to help?
Help for c# code.gh (1.5 MB)

YIKES !

What is that thing? 240 lines in main? (Sorry Giulio: early days I guess).

Other than that you should declare wiresEach as List in order to use indexing (and the Count Method):


Note: if your goal is just to Insert/Bake geometry into the Rhino document, with custom attributes … well … I have far more “modern” things. Notify in case that you need one (but you should EXPLICITLY describe what you are after).

PS: What is this chaos? Is a Graph due to some Prox Method? You want to Cluster the Lines according to some Length Interval divisions (user defined) and then assign Colors? (if yes that’s very easy - just a single LINQ GroupBy line - and real-time fast).

PS: In real life for that sort of Clustering we use only 2 “basic” Colors: say Green for the smallest, Red for the biggest and a linear interpolation between these 2.

1 Like