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

Function sweep

cadquery/occ_impl/shapes.py:7127–7245  ·  view source on GitHub ↗

Sweep edge, wire or face along a path. For faces cap has no effect. Do not mix faces with other types.

(
    s: Shape,
    path: Shape,
    aux: Shape | None = None,
    cap: bool = False,
    transition: Literal["transformed", "round", "right"] = "transformed",
    history: History | None = None,
    name: str | None = None,
)

Source from the content-addressed store, hash-verified

7125
7126@multidispatch
7127def sweep(
7128 s: Shape,
7129 path: Shape,
7130 aux: Shape | None = None,
7131 cap: bool = False,
7132 transition: Literal["transformed", "round", "right"] = "transformed",
7133 history: History | None = None,
7134 name: str | None = None,
7135) -> Shape:
7136 """
7137 Sweep edge, wire or face along a path. For faces cap has no effect.
7138 Do not mix faces with other types.
7139 """
7140
7141 spine = _get_one_wire(path)
7142
7143 results: list[TopoDS_Shape] = []
7144 builders = []
7145
7146 def _make_builder() -> BRepOffsetAPI_MakePipeShell:
7147
7148 rv = BRepOffsetAPI_MakePipeShell(spine.wrapped)
7149 if aux:
7150 rv.SetMode(_get_one_wire(aux).wrapped, True)
7151 else:
7152 rv.SetMode(False)
7153
7154 rv.SetTransitionMode(_trans_mode_dict[transition])
7155
7156 return rv
7157
7158 # try to get faces
7159 faces = s.Faces()
7160
7161 # if faces were supplied
7162 if faces:
7163 # for history handling
7164 tops_hist = []
7165 bots_hist = []
7166 solid_hist = History()
7167
7168 for f in faces:
7169 builder = _make_builder()
7170 builders.append(builder)
7171
7172 builder.Add(f.outerWire().wrapped, False, False)
7173 builder.Build()
7174 builder.MakeSolid()
7175
7176 # for bookkeeping of inner sweeps and cap construction
7177 builders_inner = []
7178 tops = []
7179 bots = []
7180 sides = []
7181
7182 # extract the outer side and initial cap
7183 bot = Shape(builder.FirstShape())
7184 top = Shape(builder.LastShape())

Callers 6

test_extendFunction · 0.90
test_ctrlPtsFunction · 0.85
test_sweepFunction · 0.85
test_sweep_auxFunction · 0.85
test_checkFunction · 0.85
test_history_sweepFunction · 0.85

Calls 15

_get_one_wireFunction · 0.85
HistoryClass · 0.85
_make_builderFunction · 0.85
ShapeClass · 0.85
compoundFunction · 0.85
_compound_or_shapeFunction · 0.85
solidFunction · 0.85
_update_historyFunction · 0.85
_remap_history_valuesFunction · 0.85
_get_wiresFunction · 0.85
_get_face_lists_strictFunction · 0.85
_get_wire_lists_strictFunction · 0.85

Tested by 6

test_extendFunction · 0.72
test_ctrlPtsFunction · 0.68
test_sweepFunction · 0.68
test_sweep_auxFunction · 0.68
test_checkFunction · 0.68
test_history_sweepFunction · 0.68