Same as each(), except arg is translated by the positions on the stack. If arg is a callback function, then the function is called for each point on the stack, and the resulting shape is used. :return: CadQuery object which contains a list of vectors (points ) on its stack.
(
self: T,
arg: Union[Shape, "Workplane", Callable[[Location], Shape]],
useLocalCoordinates: bool = False,
combine: CombineMode = False,
clean: bool = True,
)
| 2436 | return self._combineWithBase(results, combine, clean) |
| 2437 | |
| 2438 | def eachpoint( |
| 2439 | self: T, |
| 2440 | arg: Union[Shape, "Workplane", Callable[[Location], Shape]], |
| 2441 | useLocalCoordinates: bool = False, |
| 2442 | combine: CombineMode = False, |
| 2443 | clean: bool = True, |
| 2444 | ) -> T: |
| 2445 | """ |
| 2446 | Same as each(), except arg is translated by the positions on the stack. If arg is a callback function, then the function is called for each point on the stack, and the resulting shape is used. |
| 2447 | :return: CadQuery object which contains a list of vectors (points ) on its stack. |
| 2448 | |
| 2449 | :param useLocalCoordinates: should points be in local or global coordinates |
| 2450 | :param combine: True or "a" to combine the resulting solid with parent solids if found, |
| 2451 | "cut" or "s" to remove the resulting solid from the parent solids if found. |
| 2452 | False to keep the resulting solid separated from the parent solids. |
| 2453 | :param clean: call :meth:`clean` afterwards to have a clean shape |
| 2454 | |
| 2455 | |
| 2456 | The resulting object has a point on the stack for each object on the original stack. |
| 2457 | Vertices and points remain a point. Faces, Wires, Solids, Edges, and Shells are converted |
| 2458 | to a point by using their center of mass. |
| 2459 | |
| 2460 | If the stack has zero length, a single point is returned, which is the center of the current |
| 2461 | workplane/coordinate system |
| 2462 | """ |
| 2463 | |
| 2464 | # convert stack to a list of points |
| 2465 | pnts = [] |
| 2466 | plane = self.plane |
| 2467 | loc = self.plane.location |
| 2468 | |
| 2469 | if len(self.objects) == 0: |
| 2470 | # nothing on the stack. here, we'll assume we should operate with the |
| 2471 | # origin as the context point |
| 2472 | pnts.append(Location()) |
| 2473 | else: |
| 2474 | for o in self.objects: |
| 2475 | if isinstance(o, (Vector, Shape)): |
| 2476 | pnts.append(loc.inverse * Location(plane, o.Center())) |
| 2477 | elif isinstance(o, Sketch): |
| 2478 | pnts.append(loc.inverse * Location(plane, o._faces.Center())) |
| 2479 | else: |
| 2480 | pnts.append(o) |
| 2481 | |
| 2482 | if isinstance(arg, Workplane): |
| 2483 | if useLocalCoordinates: |
| 2484 | res = [ |
| 2485 | v.moved(p).move(loc) |
| 2486 | for v in arg.vals() |
| 2487 | for p in pnts |
| 2488 | if isinstance(v, Shape) |
| 2489 | ] |
| 2490 | else: |
| 2491 | res = [ |
| 2492 | v.moved(p * loc) |
| 2493 | for v in arg.vals() |
| 2494 | for p in pnts |
| 2495 | if isinstance(v, Shape) |