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

Method box

cadquery/cq.py:3954–4019  ·  view source on GitHub ↗

Return a 3d box with specified dimensions for each object on the stack. :param length: box size in X direction :param width: box size in Y direction :param height: box size in Z direction :param centered: If True, the box will be centered around the referenc

(
        self: T,
        length: float,
        width: float,
        height: float,
        centered: Union[bool, Tuple[bool, bool, bool]] = True,
        combine: CombineMode = True,
        clean: bool = True,
    )

Source from the content-addressed store, hash-verified

3952 return self.eachpoint(lambda loc: s.moved(loc), True, combine, clean)
3953
3954 def box(
3955 self: T,
3956 length: float,
3957 width: float,
3958 height: float,
3959 centered: Union[bool, Tuple[bool, bool, bool]] = True,
3960 combine: CombineMode = True,
3961 clean: bool = True,
3962 ) -> T:
3963 """
3964 Return a 3d box with specified dimensions for each object on the stack.
3965
3966 :param length: box size in X direction
3967 :param width: box size in Y direction
3968 :param height: box size in Z direction
3969 :param centered: If True, the box will be centered around the reference point.
3970 If False, the corner of the box will be on the reference point and it will
3971 extend in the positive x, y and z directions. Can also use a 3-tuple to
3972 specify centering along each axis.
3973 :param combine: should the results be combined with other solids on the stack
3974 (and each other)?
3975 :param clean: call :meth:`clean` afterwards to have a clean shape
3976
3977 One box is created for each item on the current stack. If no items are on the stack, one box
3978 using the current workplane center is created.
3979
3980 If combine is true, the result will be a single object on the stack. If a solid was found
3981 in the chain, the result is that solid with all boxes produced fused onto it otherwise, the
3982 result is the combination of all the produced boxes.
3983
3984 If combine is false, the result will be a list of the boxes produced.
3985
3986 Most often boxes form the basis for a part::
3987
3988 # make a single box with lower left corner at origin
3989 s = Workplane().box(1, 2, 3, centered=False)
3990
3991 But sometimes it is useful to create an array of them::
3992
3993 # create 4 small square bumps on a larger base plate:
3994 s = (
3995 Workplane()
3996 .box(4, 4, 0.5)
3997 .faces(">Z")
3998 .workplane()
3999 .rect(3, 3, forConstruction=True)
4000 .vertices()
4001 .box(0.25, 0.25, 0.25, combine=True)
4002 )
4003
4004 """
4005
4006 if isinstance(centered, bool):
4007 centered = (centered, centered, centered)
4008
4009 offset = Vector()
4010 if centered[0]:
4011 offset += Vector(-length / 2, 0, 0)

Callers 15

showablesFunction · 0.80
test_repr_javascriptMethod · 0.80
test_mirrorMethod · 0.80
test_all_planesMethod · 0.80
test_bad_plane_inputMethod · 0.80
test_mirror_axisMethod · 0.80
test_mirror_workplaneMethod · 0.80
wpFunction · 0.80
importBoxMethod · 0.80
importCompoundMethod · 0.80

Calls 4

eachpointMethod · 0.95
VectorClass · 0.85
makeBoxMethod · 0.80
movedMethod · 0.45

Tested by 15

showablesFunction · 0.64
test_repr_javascriptMethod · 0.64
test_mirrorMethod · 0.64
test_all_planesMethod · 0.64
test_bad_plane_inputMethod · 0.64
test_mirror_axisMethod · 0.64
test_mirror_workplaneMethod · 0.64
wpFunction · 0.64
importBoxMethod · 0.64
importCompoundMethod · 0.64