Skip to content

Commit 9bd1cb6

Browse files
Sketch distribute fix (#1826)
* Fix locationAt for planar cases * Try suggestion of @lorenzcode * Black fix * Add a test
1 parent 2ad954c commit 9bd1cb6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

cadquery/occ_impl/shapes.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2184,7 +2184,12 @@ def locationAt(
21842184
T = gp_Trsf()
21852185
if planar:
21862186
T.SetTransformation(
2187-
gp_Ax3(pnt, gp_Dir(0, 0, 1), gp_Dir(normal.XYZ())), gp_Ax3()
2187+
gp_Ax3(
2188+
pnt,
2189+
gp_Dir(0, 0, 1),
2190+
gp_Dir(Vector(0, 0, 1).cross(Vector(tangent)).normalized().wrapped),
2191+
),
2192+
gp_Ax3(),
21882193
)
21892194
else:
21902195
T.SetTransformation(

tests/test_sketch.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ def test_distribute():
193193

194194
assert s5._selection[0].Center().toTuple() == approx((0.0, 6.0, 0.0))
195195

196+
# make sure that we can use distribute on straight lines
197+
_ = Sketch().segment((0, 0), (10, 0)).edges().distribute(3).rect(1, 2)
198+
196199

197200
def test_rarray():
198201

0 commit comments

Comments
 (0)