From 634d2c34c4bab6a453833722470c00f48060e688 Mon Sep 17 00:00:00 2001 From: AU Date: Fri, 25 Apr 2025 09:09:14 +0200 Subject: [PATCH 1/4] Fix locationAt for planar cases --- cadquery/occ_impl/shapes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cadquery/occ_impl/shapes.py b/cadquery/occ_impl/shapes.py index 040712235..229e03948 100644 --- a/cadquery/occ_impl/shapes.py +++ b/cadquery/occ_impl/shapes.py @@ -2184,7 +2184,7 @@ def locationAt( T = gp_Trsf() if planar: T.SetTransformation( - gp_Ax3(pnt, gp_Dir(0, 0, 1), gp_Dir(normal.XYZ())), gp_Ax3() + gp_Ax3(pnt, gp_Dir(0, 0, 1), gp_Dir(tangent.XYZ())), gp_Ax3() ) else: T.SetTransformation( From 1f660e45f84c358bd3bd951f3513bd1f574d3362 Mon Sep 17 00:00:00 2001 From: AU Date: Mon, 5 May 2025 13:11:46 +0200 Subject: [PATCH 2/4] Try suggestion of @lorenzcode --- cadquery/occ_impl/shapes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cadquery/occ_impl/shapes.py b/cadquery/occ_impl/shapes.py index 229e03948..b74df04b5 100644 --- a/cadquery/occ_impl/shapes.py +++ b/cadquery/occ_impl/shapes.py @@ -2184,7 +2184,7 @@ def locationAt( T = gp_Trsf() if planar: T.SetTransformation( - gp_Ax3(pnt, gp_Dir(0, 0, 1), gp_Dir(tangent.XYZ())), gp_Ax3() + gp_Ax3(pnt, gp_Dir(0, 0, 1), gp_Dir(Vector(0, 0, 1).cross(Vector(tangent)).normalized().wrapped)), gp_Ax3() ) else: T.SetTransformation( From 52df75e840ad185c1800db6076ad1233a791d599 Mon Sep 17 00:00:00 2001 From: AU Date: Mon, 5 May 2025 14:41:22 +0200 Subject: [PATCH 3/4] Black fix --- cadquery/occ_impl/shapes.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cadquery/occ_impl/shapes.py b/cadquery/occ_impl/shapes.py index b74df04b5..982b2c6bf 100644 --- a/cadquery/occ_impl/shapes.py +++ b/cadquery/occ_impl/shapes.py @@ -2184,7 +2184,12 @@ def locationAt( T = gp_Trsf() if planar: T.SetTransformation( - gp_Ax3(pnt, gp_Dir(0, 0, 1), gp_Dir(Vector(0, 0, 1).cross(Vector(tangent)).normalized().wrapped)), gp_Ax3() + gp_Ax3( + pnt, + gp_Dir(0, 0, 1), + gp_Dir(Vector(0, 0, 1).cross(Vector(tangent)).normalized().wrapped), + ), + gp_Ax3(), ) else: T.SetTransformation( From 182795aaecaa102d4cb2280c5319f2b96245ae08 Mon Sep 17 00:00:00 2001 From: AU Date: Tue, 6 May 2025 08:44:39 +0200 Subject: [PATCH 4/4] Add a test --- tests/test_sketch.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_sketch.py b/tests/test_sketch.py index 2e21ae482..a75241d40 100644 --- a/tests/test_sketch.py +++ b/tests/test_sketch.py @@ -193,6 +193,9 @@ def test_distribute(): assert s5._selection[0].Center().toTuple() == approx((0.0, 6.0, 0.0)) + # make sure that we can use distribute on straight lines + _ = Sketch().segment((0, 0), (10, 0)).edges().distribute(3).rect(1, 2) + def test_rarray():