diff --git a/src/build123d/operations_generic.py b/src/build123d/operations_generic.py index 66001538..12a5118c 100644 --- a/src/build123d/operations_generic.py +++ b/src/build123d/operations_generic.py @@ -771,8 +771,7 @@ def project( projected_shapes = [] obj: Shape for obj in face_list + line_list: - obj_to_screen = (target.center() - obj.center()).normalized() - if workplane.from_local_coords(obj_to_screen).Z < 0: + if workplane.to_local_coords(obj.center()).Z > 0: projection_direction = -workplane.z_dir * projection_flip else: projection_direction = workplane.z_dir * projection_flip @@ -790,7 +789,7 @@ def project( projected_points = [] for pnt in point_list: pnt_to_target = (workplane.origin - pnt).normalized() - if workplane.from_local_coords(pnt_to_target).Z < 0: + if workplane.to_local_coords(pnt_to_target).Z < 0: projection_axis = -Axis(pnt, workplane.z_dir * projection_flip) else: projection_axis = Axis(pnt, workplane.z_dir * projection_flip) diff --git a/src/build123d/topology.py b/src/build123d/topology.py index 077ab01c..383228b3 100644 --- a/src/build123d/topology.py +++ b/src/build123d/topology.py @@ -6043,6 +6043,9 @@ def project_to_shape( for target_face in target_object.faces(): intersected_faces.extend(face_extruded.intersect(target_face).faces()) + if len(intersected_faces) == 0: + return ShapeList() + # intersected faces may be fragmented so we'll put them back together sewed_face_list = Face.sew_faces(intersected_faces) sewed_faces = ShapeList() diff --git a/tests/test_build_generic.py b/tests/test_build_generic.py index 69eba0d1..1caec07b 100644 --- a/tests/test_build_generic.py +++ b/tests/test_build_generic.py @@ -665,7 +665,7 @@ def test_project_to_sketch1(self): def test_project_to_sketch2(self): with BuildPart() as test2: Box(4, 4, 1) - with BuildSketch(Plane.XY.offset(0.1)) as c: + with BuildSketch(Plane.XY.offset(2)) as c: Rectangle(1, 1) project() extrude(amount=1)