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

Method rarray

cadquery/cq.py:1392–1434  ·  view source on GitHub ↗

Creates an array of points and pushes them onto the stack. If you want to position the array at another point, create another workplane that is shifted to the position you would like to use as a reference :param xSpacing: spacing between points in the x direction (

(
        self: T,
        xSpacing: float,
        ySpacing: float,
        xCount: int,
        yCount: int,
        center: Union[bool, Tuple[bool, bool]] = True,
    )

Source from the content-addressed store, hash-verified

1390 return rv
1391
1392 def rarray(
1393 self: T,
1394 xSpacing: float,
1395 ySpacing: float,
1396 xCount: int,
1397 yCount: int,
1398 center: Union[bool, Tuple[bool, bool]] = True,
1399 ) -> T:
1400 """
1401 Creates an array of points and pushes them onto the stack.
1402 If you want to position the array at another point, create another workplane
1403 that is shifted to the position you would like to use as a reference
1404
1405 :param xSpacing: spacing between points in the x direction ( must be >= 0)
1406 :param ySpacing: spacing between points in the y direction ( must be >= 0)
1407 :param xCount: number of points ( > 0 )
1408 :param yCount: number of points ( > 0 )
1409 :param center: If True, the array will be centered around the workplane center.
1410 If False, the lower corner will be on the reference point and the array will
1411 extend in the positive x and y directions. Can also use a 2-tuple to specify
1412 centering along each axis.
1413 """
1414
1415 if (xSpacing <= 0 and ySpacing <= 0) or xCount < 1 or yCount < 1:
1416 raise ValueError("Spacing and count must be > 0 in at least one direction")
1417
1418 if isinstance(center, bool):
1419 center = (center, center)
1420
1421 lpoints = [] # coordinates relative to bottom left point
1422 for x in range(xCount):
1423 for y in range(yCount):
1424 lpoints.append(Vector(xSpacing * x, ySpacing * y))
1425
1426 # shift points down and left relative to origin if requested
1427 offset = Vector()
1428 if center[0]:
1429 offset += Vector(-xSpacing * (xCount - 1) * 0.5, 0)
1430 if center[1]:
1431 offset += Vector(0, -ySpacing * (yCount - 1) * 0.5)
1432 lpoints = [x + offset for x in lpoints]
1433
1434 return self.pushPoints(lpoints)
1435
1436 def polarArray(
1437 self: T,

Callers 13

test_rarrayFunction · 0.45
s2Function · 0.45
test_sanitizeFunction · 0.45
testRectArrayMethod · 0.45
testLegoBrickMethod · 0.45
test_getitemMethod · 0.45
test_invokeMethod · 0.45
test_workplane_iterMethod · 0.45

Calls 3

pushPointsMethod · 0.95
VectorClass · 0.85
appendMethod · 0.80

Tested by 12

test_rarrayFunction · 0.36
s2Function · 0.36
test_sanitizeFunction · 0.36
testRectArrayMethod · 0.36
testLegoBrickMethod · 0.36
test_getitemMethod · 0.36
test_invokeMethod · 0.36
test_workplane_iterMethod · 0.36