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

Method center

cadquery/cq.py:1522–1551  ·  view source on GitHub ↗

Shift local coordinates to the specified location. The location is specified in terms of local coordinates. :param x: the new x location :param y: the new y location :returns: the Workplane object, with the center adjusted. The current point is set

(self: T, x: float, y: float)

Source from the content-addressed store, hash-verified

1520 return self.newObject(vecs)
1521
1522 def center(self: T, x: float, y: float) -> T:
1523 """
1524 Shift local coordinates to the specified location.
1525
1526 The location is specified in terms of local coordinates.
1527
1528 :param x: the new x location
1529 :param y: the new y location
1530 :returns: the Workplane object, with the center adjusted.
1531
1532 The current point is set to the new center.
1533 This method is useful to adjust the center point after it has been created automatically on
1534 a face, but not where you'd like it to be.
1535
1536 In this example, we adjust the workplane center to be at the corner of a cube, instead of
1537 the center of a face, which is the default::
1538
1539 # this workplane is centered at x=0.5,y=0.5, the center of the upper face
1540 s = Workplane().box(1, 1, 1).faces(">Z").workplane()
1541
1542 s = s.center(-0.5, -0.5) # move the center to the corner
1543 t = s.circle(0.25).extrude(0.2)
1544 assert t.faces().size() == 9 # a cube with a cylindrical nub at the top right corner
1545
1546 The result is a cube with a round boss on the corner
1547 """
1548 new_origin = self.plane.toWorldCoords((x, y))
1549 n = self.newObject([new_origin])
1550 n.plane.setOrigin2d(x, y)
1551 return n
1552
1553 def lineTo(self: T, x: float, y: float, forConstruction: bool = False) -> T:
1554 """

Callers 15

testOccBottleMethod · 0.95
testWorkplaneCenterMethod · 0.95
test_fused_assemblyFunction · 0.80
testPolarArrayMethod · 0.80
testUnionsMethod · 0.80

Calls 3

newObjectMethod · 0.95
toWorldCoordsMethod · 0.80
setOrigin2dMethod · 0.80

Tested by 15

testOccBottleMethod · 0.76
testWorkplaneCenterMethod · 0.76
test_fused_assemblyFunction · 0.64
testPolarArrayMethod · 0.64
testUnionsMethod · 0.64