algorithmic modeling for Rhino
Hello Guys,
I am starting to learn C#, I have a bit of a problem, I am trying use the
Crv.OffsetOnSurface
But it seam that in some occasions it throws a null Crv, I can fix this just by multiplying the Distance Value by -1, but i would like to run an internal test using conditional but I can figure out how to do it. I try Both methods but no result...
Any help would be greatly appreciated!
Best!
private void RunScript(Surface Srf, Curve Crv, double Dis, double Tolerance, ref object A){
Curve[] Crv1;
Curve[] Crv2;
Crv1 = Crv.OffsetOnSurface(Srf, Dis * -1, Tolerance);
Crv1.Count;
if ( Crv1.Count == 0) {
Crv2 = Crv.OffsetOnSurface(Srf, Dis, Tolerance);
} else {
Crv2 = Crv.OffsetOnSurface(Srf, Dis * -1, Tolerance);
}
A = Crv2;
}
"OR"
private void RunScript(Surface Srf, Curve Crv, double Dis, double Tolerance, ref object A){
Curve[] Crv1;
Curve[] Crv2;
Crv1 = Crv.OffsetOnSurface(Srf, Dis * -1, Tolerance);
if ( Crv1 == null) {
Crv2 = Crv.OffsetOnSurface(Srf, Dis, Tolerance);
} else {
Crv2 = Crv.OffsetOnSurface(Srf, Dis * -1, Tolerance);
}
A = Crv2;
}
Tags:
Curve[] curves = Crv.OffsetOnSurface(Srf, Dis, Tolerance);
if (curves == null || curves.Length == 0)
curves = Crv.OffsetOnSurface(Srf, -Dis, Tolerance);
if (curves == null || curves.Length == 0)
throw new Exception("Couldn't offset curve either way");
Thanks David, it works.
you make everything look so much simpler.
Best
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by