MCPcopy
hub / github.com/CadQuery/cadquery / chamfer2D

Function chamfer2D

cadquery/occ_impl/shapes.py:7076–7099  ·  view source on GitHub ↗

Apply a 2D chamfer to a planar face.

(s: Shape, verts: Shape, d: float)

Source from the content-addressed store, hash-verified

7074
7075
7076def chamfer2D(s: Shape, verts: Shape, d: float) -> Shape:
7077 """
7078 Apply a 2D chamfer to a planar face.
7079 """
7080
7081 f = _get_one(s, "Face")
7082
7083 bldr = BRepFilletAPI_MakeFillet2d(tcast(TopoDS_Face, f.wrapped))
7084 edge_map = s._entitiesFrom("Vertex", "Edge")
7085
7086 for v in verts.vertices():
7087 edges = edge_map[v]
7088 if len(edges) < 2:
7089 raise ValueError("Cannot chamfer at this location")
7090
7091 e1, e2 = edges
7092
7093 bldr.AddChamfer(
7094 tcast(TopoDS_Edge, e1.wrapped), tcast(TopoDS_Edge, e2.wrapped), d, d
7095 )
7096
7097 bldr.Build()
7098
7099 return _compound_or_shape(bldr.Shape())
7100
7101
7102def fillet2D(s: Shape, verts: Shape, r: float) -> Shape:

Callers 1

test_chamfer2DFunction · 0.85

Calls 4

_get_oneFunction · 0.85
_compound_or_shapeFunction · 0.85
_entitiesFromMethod · 0.80
verticesMethod · 0.45

Tested by 1

test_chamfer2DFunction · 0.68