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:
<?php 
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=0; i<targetIDs.Length; i++)
  {
    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:
<?php 
List<int> Ranges(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; i <= end; i++) result.Add(i);
        } else result.Add(int.Parse(part));
    }
    return result;
    List<int> listA = 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
#6
(06-30-2025, 02:33 AM)jcjworks Wrote:
(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.

I agree, vector math would be incredible. For now, in the "By value" of "Vector Data" tab on Custom Properties operator - the x,y,z components are all separated, so you can't really easily apply value operators to them. Maybe a "combined" option so we can apply math that way would be very useful. I know I would love to use this esp for turbulence applying to position over time. Right now I have to use Script operator for that.
  Reply


Forum Jump: