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

Method named

cadquery/occ_impl/geom.py:457–505  ·  view source on GitHub ↗

Create a predefined Plane based on the conventional names. :param stdName: one of (XY|YZ|ZX|XZ|YX|ZY|front|back|left|right|top|bottom) :type stdName: string :param origin: the desired origin, specified in global coordinates :type origin: 3-tuple of the origin of the

(cls: Type["Plane"], stdName: str, origin=(0, 0, 0))

Source from the content-addressed store, hash-verified

455
456 @classmethod
457 def named(cls: Type["Plane"], stdName: str, origin=(0, 0, 0)) -> "Plane":
458 """Create a predefined Plane based on the conventional names.
459
460 :param stdName: one of (XY|YZ|ZX|XZ|YX|ZY|front|back|left|right|top|bottom)
461 :type stdName: string
462 :param origin: the desired origin, specified in global coordinates
463 :type origin: 3-tuple of the origin of the new plane, in global coordinates.
464
465 Available named planes are as follows. Direction references refer to
466 the global directions.
467
468 =========== ======= ======= ======
469 Name xDir yDir zDir
470 =========== ======= ======= ======
471 XY +x +y +z
472 YZ +y +z +x
473 ZX +z +x +y
474 XZ +x +z -y
475 YX +y +x -z
476 ZY +z +y -x
477 front +x +y +z
478 back -x +y -z
479 left +z +y -x
480 right -z +y +x
481 top +x -z +y
482 bottom +x +z -y
483 =========== ======= ======= ======
484 """
485
486 namedPlanes = {
487 # origin, xDir, normal
488 "XY": Plane(origin, (1, 0, 0), (0, 0, 1)),
489 "YZ": Plane(origin, (0, 1, 0), (1, 0, 0)),
490 "ZX": Plane(origin, (0, 0, 1), (0, 1, 0)),
491 "XZ": Plane(origin, (1, 0, 0), (0, -1, 0)),
492 "YX": Plane(origin, (0, 1, 0), (0, 0, -1)),
493 "ZY": Plane(origin, (0, 0, 1), (-1, 0, 0)),
494 "front": Plane(origin, (1, 0, 0), (0, 0, 1)),
495 "back": Plane(origin, (-1, 0, 0), (0, 0, -1)),
496 "left": Plane(origin, (0, 0, 1), (-1, 0, 0)),
497 "right": Plane(origin, (0, 0, -1), (1, 0, 0)),
498 "top": Plane(origin, (1, 0, 0), (0, 1, 0)),
499 "bottom": Plane(origin, (1, 0, 0), (0, -1, 0)),
500 }
501
502 try:
503 return namedPlanes[stdName]
504 except KeyError:
505 raise ValueError("Supported names are {}".format(list(namedPlanes.keys())))
506
507 @classmethod
508 def XY(cls, origin=(0, 0, 0), xDir=Vector(1, 0, 0)):

Callers 15

__init__Method · 0.80
XYMethod · 0.80
YZMethod · 0.80
ZXMethod · 0.80
XZMethod · 0.80
YXMethod · 0.80
ZYMethod · 0.80
frontMethod · 0.80
backMethod · 0.80
leftMethod · 0.80
rightMethod · 0.80
topMethod · 0.80

Calls 1

PlaneClass · 0.85

Tested by 7

testXYPlaneBasicsMethod · 0.64
testYZPlaneBasicsMethod · 0.64
testZXPlaneBasicsMethod · 0.64
testXZPlaneBasicsMethod · 0.64
testYXPlaneBasicsMethod · 0.64
testZYPlaneBasicsMethod · 0.64
testInvalidPlaneMethod · 0.64