28 lines
870 B
Python
28 lines
870 B
Python
from build123d import Plane
|
|
from build123d import draft as _draft
|
|
|
|
_NORMAL_Z_TOLERANCE = 0.01
|
|
|
|
|
|
def validate(context, target, params):
|
|
errors = []
|
|
if target is None:
|
|
errors.append("NO_TARGET: draft_faces 需要一个实体作为输入")
|
|
return errors
|
|
|
|
side_faces = [f for f in target.faces() if abs(f.normal_at().Z) < _NORMAL_Z_TOLERANCE]
|
|
if not side_faces:
|
|
errors.append("NO_SIDE_FACES: 找不到可以拔模的竖直侧面")
|
|
return errors
|
|
|
|
|
|
def run(context, target, params):
|
|
side_faces = [f for f in target.faces() if abs(f.normal_at().Z) < _NORMAL_Z_TOLERANCE]
|
|
|
|
if params["neutral_plane"] == "bottom":
|
|
neutral = Plane.XY.offset(target.bounding_box().min.Z)
|
|
else:
|
|
neutral = Plane.XY.offset(target.bounding_box().max.Z)
|
|
|
|
return _draft(side_faces, neutral_plane=neutral, angle=params["angle"])
|