C# definition

The error moves up and down when I change something.
So, I understand that every value for recall should be in the first braces-level. I looked at other C#-scripts from Darth Vader (PeterFotiadis) to learn faster. But, I just need to find that basic code of doing this correctly I figure all out by myself.

So, in this basic code situation, what does not align in this code to the correct form?

  public List<double> fRangeLength(double start, double end, double length){
    List<double> vals = new List<double>();
    double jump = 0.0;
    if (start > end){
      jump = -1 * length;
    }
    else{
      jump = -length;
    }

    double temp = 0.0;
    if ((start - end) == 0){
      vals.Add(0);
    }
    else if (jump < 0){
      temp = start;
      while(temp > end){
        vals.Add(temp);
        temp += jump;
      }
    }
    else if (jump > 0){
      temp = start;
      while(temp < end){
        vals.Add(temp);
        temp += jump;
      }
      vals.Add(end);
    }
    return vals;
  }

example03.gh (4.0 KB)

double result = fRangeLength(0,5,1);

fRangeLength returns List< double >, not double.

I donā€™t know why you donā€™t see the line numbers in the C# code editor, btw, it is very helpfull for debug.

1 Like
if (start > end){ 
   jump = -1 * length;
} else { 
   jump = -length; 
}

this doesnā€™t have too much sense, since -1 * length is equivalent to -length, and you want to jump backwards just when start > end.

1 Like

Are you sure that the original code was reading

jump = -length; // means; "negative length"

and not this?

jump -= length;  // means; "whatever value jump had, minus length"

// Rolf

2 Likes

These tutorials by Nguyen are great!
Iā€™ve ported the mesh growth algorithm a while back to GHPython. :wink:

This example starts from a regular mesh plane:

It gets a little sluggish at 6000+ vertices, and multithreading isnā€™t available in IronPython, so I couldnā€™t implement that part. However, the R-tree algorithm is superior anyways! :smiley:

Hereā€™s a rendered mesh with 12000 vertices:

It always reminds me of:

https://imgur.com/lcEyFG3

A lucky mishap, I recon! :smiley:

@RIL, happy birthday, dude! :beers:

1 Like

I do not know what to do.

You are saying:

But what now? I removed the .0ā€™sā€¦
And I am pretty sure you meant something else me not understanding it well because ā€œI am only level 1,ā€ sorry.
You know what a Magikarp is? I have to go to level 20 to become a Gyarados, that will take a while probablyā€¦

I am stuck at the same place in my script, line 58.

an easy fix will be

var result =  fRangeLength(0,5,1);

but you seem to miss a lot of the basics. It might be best to really start reading a basic c# tutorial and get familiar with variables, list, arrays etc.