Hi!
I am having some issues projecting a surface (sufaceA), which is not a perfect rectangle, but planar, onto another surface (surfaceB). My approach is to take the boundary curves from the surfaceA and the basePlane from surfaceB and use Curve.ProjectToPlane. Then i use those curves to Brep.CreatePlanarBreps with the RhinoTolerance set to 0.000001.
My problem is, that the projected surfaceA seems to be corrected sometimes, why and where?
For example I use a surfaceA, project it - works perfectly and the area is still the same
Then i use the same surfaceA that was just projected, move it a bit and project it again, and the result is a perfect rectangle with a different area.
Any hints would be great, i have this encapsulated into a try method within a command:
var targetSurfaceBrep = targetSurface.ToBrep();
var surfaceBoundaryCurves = targetSurfaceBrep.DuplicateNakedEdgeCurves(true, false);
if (surfaceBoundaryCurves == null || surfaceBoundaryCurves.Length == 0)
{
return false;
}
var projectedCurves = surfaceBoundaryCurves
.Select(curve => Curve.ProjectToPlane(curve, basePlane))
.Where(projectedCurve => projectedCurve != null)
.ToList();
if (projectedCurves.Count == 0)
{
return false;
}
var projectedSurface = Brep.CreatePlanarBreps(projectedCurves, RhinoDoc.ActiveDoc.ModelAbsoluteTolerance)?.FirstOrDefault();
if (projectedSurface == null)
{
return false;
}
var polyline = new Polyline(projectedSurface.Vertices.Select(v => v.Location));
if (!polyline.IsClosed) polyline.Add(polyline[0]);
var polylineCurve = polyline.ToNurbsCurve();
if (polylineCurve == null)
{
return false;
}
var targetObject = RhinoDoc.ActiveDoc.Objects.Find(targetSurfaceObjRef.ObjectId);
if (targetObject == null)
{
return false;
}
RhinoDoc.ActiveDoc.Objects.Delete(targetSurfaceObjRef, true);
return true;