Length of Sketch.slot() incorrect
- Dominant language
- Python
- Stars
- 5.8k
- Forks
- 541
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 5
Description
The `Sketch.slot()` method produces a slot with the incorrect length (w+h). Here is an illustration of how it doesn't agree with the `Workplane.slot2D()` and the fixed code:
```python
from typing import Literal, Optional
import cadquery as cq
from cadquery import Vector, Edge, Wire
from cadquery.sketch import Real, Modes
from cadquery.cq import T
def _fixed_slot(
self: T,
w: Real,
h: Real,
angle: Real = 0,
mode: Modes = "a",
tag: Optional[str] = None,
) -> T:
"""
Construct a slot-shaped face.
"""
p1 = Vector(-w / 2 + h / 2, h / 2)
p2 = Vector(w / 2 - h / 2, h / 2)
p3 = Vector(-w / 2 + h / 2, -h / 2)
p4 = Vector(w / 2 - h / 2, -h / 2)
p5 = Vector(-w / 2, 0)
p6 = Vector(w / 2, 0)
e1 = Edge.makeLine(p1, p2)
e2 = Edge.makeThreePointArc(p2, p6, p4)
e3 = Edge.makeLine(p4, p3)
e4 = Edge.makeThreePointArc(p3, p5, p1)
wire = Wire.assembleEdges((e1, e2, e3, e4))
return self.face(wire, angle, mode, tag)
cq.Sketch.fixed_slot = _fixed_slot
workplane_slot = cq.Workplane("XZ").slot2D(10, 5)
workplane_rect = cq.Workplane("XZ").rect(10, 5)
sketch_slot = cq.Sketch().slot(10, 5)
sketch_fixed_slot = cq.Sketch().fixed_slot(10, 5)
sketch_rect = cq.Sketch().rect(10, 5)
if "show_object" in locals():
show_object(workplane_slot, name="workplane_slot")
show_object(workplane_rect, name="workplane_rect")
show_object(sketch_slot, name="sketch_slot", options={"color": "blue"})
show_object(sketch_fixed_slot, name="sketch_fixed_slot", options={"color": "red"})
show_object(sketch_rect, name="sketch_rect", options={"alpha": 0.5})
```

Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.