C# scripting, range()
#1
In C# scripting, how can I use the range function to generate a sequence of integers? What is the syntax for range? Sometimes I need a large set of numbers, like range(5, 19).
PHP Code:
public void simulationStep()
{        
    
    
Point3[] targetPositions = new Point3[] {new Point3(0,0,10), new Point3(10,0,0),new Point3(0,10,0)};


    int[] targetIDs = new int[] {1,3,9};
    int[] bd = new int[] {5,7,13};
    for(int i=0i<targetIDs.Lengthi++)
   {
    tf.SetPos(targetIDs[i], targetPositions[i]);
    tf.NewBind(targetIDs[i],bd[i],0,0,0); 
    
   

  Reply
#2
Is using a loop structure like“ for (int rangeA = 6; rangeA <= 12; rangeA++){} ”the only approach available?
  Reply
#3
I'm using this list-to-matrix conversion method, but I'm not sure if it's the most performance-optimized approach in tyflow with C#?
PHP Code:
List<intRanges(string input) {
    var result = new List<int>();
    foreach (var part in input.Split(',')) {
        if (part.Contains("-")) {
            var range part.Split('-');
            int start int.Parse(range[0]), end int.Parse(range[1]);
            for (int i start<= endi++) result.Add(i);
        } else result.Add(int.Parse(part));
    }
    return result;
    List<intlistA Ranges("1,6-8,17");
    int[] targetIDs listA.ToArray();

  Reply
#4
All C# syntax is valid - and the Math.Random library has range functions, or you can use tyFlow's exposed random range functions. Just initialize a generlic list of ints and fill with random values.
  Reply
#5
(06-27-2025, 03:55 PM)tyFlow Wrote: All C# syntax is valid - and the Math.Random library has range functions, or you can use tyFlow's exposed random range functions. Just initialize a generlic list of ints and fill with random values.
Tongue Tongue
Additionally, it would be great if the vector attributes for custom properties operators could provide quick access to common geometry properties like normals and tangents. Even better would be the addition of mathematical operators for vectors.
  Reply


Forum Jump: