0

Gh components

Gh Scripts

Console Script

Console Output

In my console app i can get a perfect return but when i try to increment it in grasshopper it returns only nulls. So it might be a obvious answer but i’ve been trying to solve this for five days and i’m not familiar working without debug system. I can’t find where is the problem and why it is not giving me the output. I’m open to any suggestions or changes. Thanks.

If you want to try it out or make changes i'm adding code below;

int count = 0;

int maxval = 510;
            
var numbers = new List<int>() { 349, 349, 349, 349, 348, 348, 345, 345, 345, 330, 325, 325, 325, 325, 325, 325, 325, 325, 325, 325, 325, 325, 325, 315, 315, 315, 315, 315, 314, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 299, 299, 299, 298, 298, 298, 298, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 280, 280, 280, 280, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, 264, 264, 260, 260, 260, 260, 255, 255, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 225, 220, 220, 220, 220, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 199, 199, 199, 199, 198, 190, 190, 190, 190, 190, 190, 190, 175, 175, 175, 175, 175, 175, 175, 175, 174, 174, 170, 170, 165, 165, 165, 165, 160, 160, 155, 155, 155, 155, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 149, 145, 145, 145, 145, 145, 145, 145, 140, 139, 139, 139, 139, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 124, 124, 124, 124, 115, 115, 115, 115, 115, 115, 115, 115, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 74, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 50, 50, 50, 24, 20, 20, 20, 20, 10, 5, 5, 5, 5, 5, 5, 5 };

for (int i = 0; i < numbers.Count; i++)
{
    for (int j = 0; j < numbers.Count; j++)
    {
        if (numbers[j] < maxval - numbers[i] && numbers[j] + numbers[i] <= maxval)
        {
            numbers.RemoveAt(numbers.IndexOf(numbers[j]));
            numbers.RemoveAt(i);

            int z = numbers[j] + numbers[i];
            bool test = true;

            for (int t = 0; t < numbers.Count; t++)
            {
                if (numbers[t] < maxval - z && z + numbers[t] <= maxval)
                {
                    count++;
                    Console.WriteLine("{0} + {1} + {2} = {3} 3 block piece used and block count is: {4} ", numbers[i], numbers[j], numbers[t], z + numbers[t], count);
                    numbers.RemoveAt(numbers.IndexOf(numbers[t]));
                    test = false;
                    Console.WriteLine("Total count is: {0}", count);
                    break;
                }
            }
            if (test == true)
            {
                count++;
                Console.WriteLine("{0} + {1} = {2} 2 block piece used and block count is: {3} ", numbers[i], numbers[j], z, count);
                Console.WriteLine("Total count is: {0}", count);
            }
        }
    }
}
Palle Due
  • 5,929
  • 4
  • 17
  • 32
Ragijas
  • 9
  • 2

1 Answers1

0

because gh components solve for the entire script and output in the end.

rather than assigning the output parameters like A or AA to the value, you'll need to add them to a list and assign the list to A or AA etc. outside the loops

visualizor
  • 80
  • 1
  • 9
  • Thanks for the answer. Tried exact same thing. Created separate lists and assigned every output with "listname.add()" function. When i try to assign that list to A or AA it returns the index itself, not the number in the index. Tried in the loop outside of the loop it doesn't work. – Ragijas Oct 11 '22 at 14:52
  • you'll probably get better answer on the rhino discourse forum. also i find it easier to format your questions for legibility. that said, i think you may have just added the index to the list not the numbers themselves... – visualizor Oct 11 '22 at 16:05