Repository navigation
Modeling bend in face with slot #2000
Replies: 2 comments
|
I think the best angle of attack here would be to use |
|
Building on @adam-urbanczyk's UV-mapping suggestion, Here is a CadQuery 2.8.0 example, with lengths in millimeters. from math import pi
import cadquery as cq
from cadquery.func import faceOn, offset, shell
def bent_slot(inner_radius=1.0, thickness=1.0, samples=50):
# The original flat coordinates are developed midsurface coordinates.
radius = inner_radius + thickness / 2
start = -10 - pi * radius / 4
end = -10 + pi * radius / 4
sketch = cq.Sketch().rect(40, 20).push([(-10, 0)]).slot(10, 1, 0, "s").reset()
flat = sketch.val()
def strip(a, b):
boundary = cq.Workplane().center((a + b) / 2, 0).rect(b - a, 20).val()
return flat.intersect(cq.Face.makeFromWires(boundary))
left, bend, right = strip(-20, start), strip(start, end), strip(end, 20)
cylinder = cq.Solid.makeCylinder(radius, 20, pnt=(0, 0, -10))
base = next(f for f in cylinder.Faces() if f.geomType() == "CYLINDER")
base = (
base.rotate((0, 0, 0), (0, 0, 1), -90)
.rotate((0, 0, 0), (1, 0, 0), 90)
.translate((start, 0, radius))
)
# Cylinder u is an angle; v runs along its axis. Map all boundary wires.
uv = bend.transformGeometry(cq.Matrix([
[1 / radius, 0, 0, -start / radius],
[0, -1, 0, 10],
[0, 0, 1, 0],
[0, 0, 0, 1],
]))
bend = faceOn(base, uv, N=samples, tol=1e-7)
right = (
right.translate((-end, 0, 0))
.rotate((0, 0, 0), (0, 1, 0), -90)
.translate((start + radius, 0, radius))
)
midsurface = shell(left, bend, right, tol=1e-6)
return offset(midsurface, thickness / 2, both=True, cap=True, tol=1e-6)
result = bent_slot()
assert result.isValid() and len(result.Solids()) == 1
# In CQ-editor or another viewer: show_object(result)
Checked with CadQuery 2.8.0 / OCCT 7.9.3: one valid solid, volume about 789.21461 mm³, and material/empty-space probes through the slot, adjacent plate and both bend seams. A fresh-process STEP readback retained the valid solid and open slot. Radius/thickness pairs (2, 0.8) and (0.5, 0.5) also produced one valid solid and passed volume and slot probes. This is a geometric construction; material bend allowance, neutral-axis shift and springback are separate. |
Uh oh!
There was an error while loading. Please reload this page.
The solution of #1996 does not preserve the slot. It looks like a different approach is needed to create a bend given a face with features such as slot/holes.
All reactions