Getting Invalid sweep2 curves

I am using sweep 2 on this geometry which I have given below to get a surface from sweep. Dont know why its giving a false surface.
my input model
image
what I want
MicrosoftTeams-image (28)
What I am getting
image
image

Here is the 3dm file
input:
squareoverhang1.3dm (72.3 KB)
output
squareoverhang2.3dm (107.5 KB)

here is my code

RhinoDoc activeDoc = RhinoDoc.ActiveDoc;
IEnumerable brepObjects1 = activeDoc.Objects.GetObjectList(ObjectType.Brep);
RhinoObject object1 = brepObjects1.ElementAt(0);
Brep Brep_body1 = Brep.TryConvertBrep(object1.Geometry);
A = object1.Geometry;
BrepFace face = Brep_body1.Faces.ElementAt(4);
A = face;
int edgeindexes = face.AdjacentEdges();
List vertices = new List();
List curves = new List();
for (int i = 0; i < face.AdjacentEdges().Length - 1; i++)
{
Curve curve = Brep_body1.Edges.ElementAt(edgeindexes[i]);
Point3d start = curve.PointAtStart;
vertices.Add(start);
curves.Add(curve);
}

//
IEnumerable brepObjects2 = activeDoc.Objects.GetObjectList(ObjectType.Curve);
RhinoObject object2 = brepObjects2.ElementAt(1);
Curve curve2 = object2.Geometry as Curve;
A = curve2;
//// // //// //////
IEnumerable brepObjects3 = activeDoc.Objects.GetObjectList(ObjectType.Curve);
RhinoObject object3 = brepObjects3.ElementAt(2);
Curve curve3 = object3.Geometry as Curve;
A = curve3.IsClosed;

//// // //// //////////
Point3d point1 = vertices[0];
double t;
curve2.ClosestPoint(point1, out t);
Point3d point2 = curve2.PointAt(t);
Line line = new Line(point1, point2);
A = point2;
//// // // ////
////
////
//// // // //////////////
Brep breps = Brep.CreateFromSweep(curve2, curve3, line.ToNurbsCurve(), true, activeDoc.ModelAbsoluteTolerance);
A = breps;
activeDoc.Objects.Add(breps[0]);
activeDoc.Views.Redraw();

To properly format your code for posting here please do the following:

image

i.e.
Three ‘backticks’ plus the name of the programming language you are using
(Python shown, you can use others)
Paste the entire code
Three more backticks

You can edit your post above to fix it…

From the image and what I can read of your code, I suspect your curve seams and directions are not aligned - you need to do that in your script before sweeping/lofting.

1 Like

Thanks it worked