Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5938

Path mapping in c#

$
0
0

@daniel.c wrote:

Hi,

Im trying to step up game and after producing some very basic scripts in python Im trying c#. Anyways, 2 questions:

Grid of points.gh (5.9 KB)

  • I would welcome any tips to simplify my messy c# script producing grid of points according to input lists of distances in X, Y coordinates.
// Create list for points
Rhino.Collections.Point3dList PtList = new Rhino.Collections.Point3dList();

// Variable for loops
double xx = 0;
double yy = 0;

// List for X and Y distance values
List<double> ListXX = new List<double>();
List<double> ListYY = new List<double>();

// Add 0 coordinates to lists X, Y
ListXX.Add(0);
ListYY.Add(0);


//Loop to create List of X coordinates
for (var i = 0; i < x.Count; i++)
{
  xx = xx + x[i];
  ListXX.Add(xx);
}

//Loop to create List of Y coordinates
for (var i = 0; i < y.Count; i++)
{
  yy = yy + y[i];
  ListYY.Add(yy);
}

// Loop to generate points
for (var i = 0; i < ListXX.Count; i++)
{
  for (var j = 0; j < ListYY.Count; j++)
  {
    PtList.Add(ListXX[i], ListYY[j], 0);
  }
}


// Outputs
A = ListXX;
B = ListYY;
C = PtList;

Regards,
Dan.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles