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

Method rarray

cadquery/sketch.py:371–394  ·  view source on GitHub ↗

Generate a rectangular array of locations.

(self: T, xs: Real, ys: Real, nx: int, ny: int)

Source from the content-addressed store, hash-verified

369 # distribute locations
370
371 def rarray(self: T, xs: Real, ys: Real, nx: int, ny: int) -> T:
372 """
373 Generate a rectangular array of locations.
374 """
375
376 if nx < 1 or ny < 1:
377 raise ValueError(f"At least 1 elements required, requested {nx}, {ny}")
378
379 locs = []
380
381 offset = Vector((nx - 1) * xs, (ny - 1) * ys) * 0.5
382 for i, j in product(range(nx), range(ny)):
383 locs.append(Location(Vector(i * xs, j * ys) - offset))
384
385 if self._selection:
386 selection: Sequence[Union[Shape, Location, Vector]] = self._selection
387 else:
388 selection = [Vector()]
389
390 return self.push(
391 (l * el if isinstance(el, Location) else l * Location(el.Center()))
392 for l in locs
393 for el in selection
394 )
395
396 def parray(self: T, r: Real, a1: Real, da: Real, n: int, rotate: bool = True) -> T:
397 """

Callers

nothing calls this directly

Calls 5

pushMethod · 0.95
VectorClass · 0.85
LocationClass · 0.85
appendMethod · 0.80
CenterMethod · 0.45

Tested by

no test coverage detected