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

Method invoke

cadquery/cq.py:4500–4524  ·  view source on GitHub ↗

Invoke a callable mapping Workplane to Workplane or None. Supports also callables that take no arguments such as breakpoint. Returns self if callable returns None. :param f: Callable to be invoked. :return: Workplane object.

(
        self: T, f: Union[Callable[[T], T], Callable[[T], None], Callable[[], None]]
    )

Source from the content-addressed store, hash-verified

4498 return self.newObject(sorted(self.objects, key=key))
4499
4500 def invoke(
4501 self: T, f: Union[Callable[[T], T], Callable[[T], None], Callable[[], None]]
4502 ) -> T:
4503 """
4504 Invoke a callable mapping Workplane to Workplane or None. Supports also
4505 callables that take no arguments such as breakpoint. Returns self if callable
4506 returns None.
4507
4508 :param f: Callable to be invoked.
4509 :return: Workplane object.
4510 """
4511
4512 arity = get_arity(f)
4513 rv = self
4514
4515 if arity == 0:
4516 f() # type: ignore
4517 elif arity == 1:
4518 res = f(self) # type: ignore
4519 if res is not None:
4520 rv = res
4521 else:
4522 raise ValueError("Provided function {f} accepts too many arguments")
4523
4524 return rv
4525
4526 def export(
4527 self: T,

Callers 2

test_invokeFunction · 0.45
test_invokeMethod · 0.45

Calls 2

get_arityFunction · 0.85
fFunction · 0.50

Tested by 2

test_invokeFunction · 0.36
test_invokeMethod · 0.36