Hi all,
i have no idea why the c# result is different to python.
No error and in my view exactly the same thing but obvious not because of different results.
Python works and c# does not.
Python
import Rhino as rh
C = [] # Sorted rig
# Order to calculate
def calculation_order(x):
if len(x) >= 0:
for j in x:
L = []
for e in x:
if e != j:
CrvEnd = rh.Geometry.CurveEnd.Both
ej = rh.Geometry.Curve.Trim(j,CrvEnd,2)
L.append(rh.Geometry.Curve.ClosestPoint(ej,e.PointAtStart,0.01)[0])
L.append(rh.Geometry.Curve.ClosestPoint(ej,e.PointAtEnd,0.01)[0])
if any(L) == False:
C.append(j)
x.remove(j)
return calculation_order(x)
calculation_order(x)
and c#
private void RunScript(List<Curve> x, ref object B)
{
List <Curve> A = calculation_order(x);
B = A;
}
// <Custom additional code>
List <Curve> C = new List <Curve> ();
List <Curve> calculation_order(List <Curve> x)
{
if (x.Count >= 0)
{
foreach (Curve j in x)
{
List<object> L = new List<object>();
foreach (Curve e in x)
{
if (e != j)
{
var CrvEnd = Rhino.Geometry.CurveEnd.Both;
Curve ej = j.Trim(CrvEnd, 2);
Point3d StartPoint = e.PointAtStart;
Point3d EndPoint = e.PointAtEnd;
double t;
bool SpClosestPt = ej.ClosestPoint(StartPoint, out t, 0.01);
bool EpClosestPt = ej.ClosestPoint(EndPoint, out t, 0.01);
L.Add(SpClosestPt);
L.Add(EpClosestPt);
}
}
if (L.Contains(false))
{
C.Add(j);
x.Remove(j);
return calculation_order(x);
}
}
}
return C;
}
// </Custom additional code>
}
I really hope someone see my fault.