The script, which is written in C# does not work when I use a 4 point create surface method. However, when I create the exact same surfaces with a 2 point surface create method it does work… I don’t quite understand why. I am using Rhino WIP on windows.
Here is the script:
private void RunScript(Surface srfA, Surface srfB, double radius, double tol, ref object A)
{
//Declare an array of surfaces
Surface[] surfaces = {};
//Check for a valid input
if (srfA != null && srfB != null)
{
//Create fillet surfaces
surfaces = Surface.CreateRollingBallFillet(srfA, srfB, radius, tol);
}
A = surfaces;
}
The main difference is in your surface UV directions, It’s not about what command you’re using, it’s about how you are using these command to make the surface.
You can reverse these directions like this:
private void RunScript(Surface srf, bool u, bool v, ref object A)
{
if (u)
srf.Reverse(0, true);
if (v)
srf.Reverse(1, true);
A = srf;
}
Arrange 2 planar surfaces like an Extruded x. Now it can create 4 valid fillets. Which fillet is the required one? Both uv point hints which fillet is the required one. I wouldn‘t pick the domain mid for this, but instead two uv points indicating the correct side. You can also create a point in space and find both surfaces closest point and use these uv points for this. But assuming surfaces are always arranged like (Extruded L) this it will work of course
private void RunScript(Surface srfA, Surface srfB, Point3d point, double radius, double tol, ref object fillets)
{
if (srfA != null && srfB != null)
{
double uA, vA , uB, vB;
srfA.ClosestPoint(point, out uA, out vA);
srfB.ClosestPoint(point, out uB, out vB);
// Juggle the pickpoint ever so slightly towards the middle of the domain
// to get a better chance of getting a valid chord.
if (uB == srfB.Domain(0).Min || uB == srfB.Domain(0).Max)
uB = 0.99 * uA + 0.01 * srfB.Domain(0).Mid;
if (vB == srfB.Domain(1).Min || vB == srfB.Domain(1).Max)
vB = 0.99 * vA + 0.01 * srfB.Domain(1).Mid;
fillets = Surface.CreateRollingBallFillet(srfA, new Point2d(uA, vA), srfB, new Point2d(uB, vB), radius, tol);
}
}
@Mahdiyar
Thank you very much for all the codes you gave! The easiest of all, in my opinion, and the most compact is your second code (RollingBallFilletOverload).
I have a question regarding this, when defining pointA you take the mid-point of the domain of surface a, then the mid-point of the domain of surface b. However, when defining pointB, you take the mid-point of the domain of surface b, and then again take the midpoint of domain of surface b.
So, my question is why not surface b, and then surface a, as it also works, but why?
P.S. I really liked the way you organized your posts,and the way you explained them as it helped see what each code does.