Build a drafted prismatic feature that can be additive or subtractive.
(
ctx: Shape,
base: Shape | None,
faces: Shape,
t: Real | Shape | tuple[Shape, Shape] | None,
angle: Real = 0.0,
additive: bool = True,
history: History | None = None,
name: str | None = None,
)
| 7687 | |
| 7688 | @multidispatch |
| 7689 | def prism( |
| 7690 | ctx: Shape, |
| 7691 | base: Shape | None, |
| 7692 | faces: Shape, |
| 7693 | t: Real | Shape | tuple[Shape, Shape] | None, |
| 7694 | angle: Real = 0.0, |
| 7695 | additive: bool = True, |
| 7696 | history: History | None = None, |
| 7697 | name: str | None = None, |
| 7698 | ) -> Shape: |
| 7699 | """ |
| 7700 | Build a drafted prismatic feature that can be additive or subtractive. |
| 7701 | """ |
| 7702 | |
| 7703 | builders = [] |
| 7704 | |
| 7705 | s_tmp = ctx.wrapped |
| 7706 | |
| 7707 | for f in _get_faces(faces): |
| 7708 | bldr: BRepFeat_MakePrism | BRepFeat_MakeDPrism |
| 7709 | # if taper is requested, use the dprism builder |
| 7710 | if angle != 0: |
| 7711 | bldr = BRepFeat_MakeDPrism( |
| 7712 | s_tmp, |
| 7713 | f.wrapped, |
| 7714 | base.face().wrapped if base else TopoDS_Face(), |
| 7715 | radians(angle), |
| 7716 | additive, |
| 7717 | False, |
| 7718 | ) |
| 7719 | # otherwise use the prism builder to get cleaner topologies |
| 7720 | else: |
| 7721 | bldr = BRepFeat_MakePrism( |
| 7722 | s_tmp, |
| 7723 | f.wrapped, |
| 7724 | base.face().wrapped if base else TopoDS_Face(), |
| 7725 | f.normalAt().toDir(), |
| 7726 | additive, |
| 7727 | False, |
| 7728 | ) |
| 7729 | |
| 7730 | builders.append(bldr) |
| 7731 | |
| 7732 | # dispatch on thickens type |
| 7733 | if isinstance(t, Shape): |
| 7734 | bldr.Perform(t.face().wrapped) |
| 7735 | elif isinstance(t, tuple): |
| 7736 | bldr.Perform(t[0].face().wrapped, t[1].face().wrapped) |
| 7737 | elif t is None: |
| 7738 | bldr.PerformThruAll() |
| 7739 | else: |
| 7740 | bldr.Perform(t) |
| 7741 | |
| 7742 | s_tmp = bldr.Shape() |
| 7743 | |
| 7744 | return _update_prism_history(ctx, base, faces, t, s_tmp, history, name, builders) |
| 7745 | |
| 7746 |