18 lines
618 B
Python
18 lines
618 B
Python
from build123d import extrude as _extrude, Vector
|
|
|
|
|
|
def validate(context, target, params):
|
|
errors = []
|
|
if target is None:
|
|
errors.append("NO_TARGET: extrude 需要一个草图作为输入")
|
|
direction = params.get("direction")
|
|
if direction is not None and Vector(direction).length < 1e-9:
|
|
errors.append("INVALID_DIRECTION: 显式拉伸方向不能为零向量")
|
|
return errors
|
|
|
|
|
|
def run(context, target, params):
|
|
if "direction" in params:
|
|
return _extrude(target, amount=params["amount"], dir=tuple(params["direction"]))
|
|
return _extrude(target, amount=params["amount"])
|