HI,
I tried to convert a panelling script from vb to c#,I cant find the error, it should be already translated completly.
Private Sub RunScript(ByVal Srf As Surface, ByVal U As Integer, ByVal V As Integer, ByRef Panels As Object)
Dim p As New List (Of NurbsSurface)
Dim ustep As Double = 1 / u
Dim vstep As Double = 1 / v
For i As Integer = 0 To u - 1
Dim j As Integer = 0
While j <= V - 1
Dim myRandom As New Random(i + j)
Dim varlength As Integer = myRandom.Next(1, 10)
If (j + varlength) > V Then
varlength = V - j
End If
Dim panelpts As New List (Of Point3d)
For k As Integer = 0 To varlength
Dim ptA As Point3d = Srf.PointAt(i * ustep, (j + k) * vstep)
Dim ptB As Point3d = Srf.PointAt((i + 1) * ustep, (j + k) * vstep)
panelpts.Add(ptA)
panelpts.Add(ptB)
Next
Dim mysurface As NurbsSurface = NurbsSurface.CreateFromPoints(panelpts, varlength + 1, 2, 3, 3)
p.Add(mysurface)
j = j + (varlength)
End While
Next
Panels = p
End Sub
Its from this page: http://wiki.theprovingground.org/scripts-paneling
my attempt so far:
private void RunScript(Surface S, int U, int V, ref object A)
{
var panels = new List<NurbsSurface>();
for(int i = 0; i < U - 1; i++)
{
int j = 0;
while (j <= V - 1)
{
Random myRandom = new Random(i + j);
int varlength = myRandom.Next(1, 10);
if ((j + varlength) > V )
varlength = V - j;
var panelPts = new List<Point3d>();
for (int k = 0; k < varlength; i++)
{
Point3d ptA = S.PointAt(i * U, (j + k) * V);
Point3d ptB = S.PointAt((i + 1) * U, (j + k) * V);
panelPts.Add(ptA);
panelPts.Add(ptB);
NurbsSurface ns = NurbsSurface.CreateFromPoints(panelPts, varlength + 1, 2, 3, 3);
panels.Add(ns);
j = j + (varlength);
}
}
}
A = panels;
}
Thanks for any hint!
Regards!
file : RandomPanels.gh (4.0 KB)