Returns a 3D sphere with the specified radius for each point on the stack. :param radius: The radius of the sphere :param direct: The direction axis for the creation of the sphere :type direct: A three-tuple :param angle1: The first angle to sweep the sphere
(
self: T,
radius: float,
direct: VectorLike = (0, 0, 1),
angle1: float = -90,
angle2: float = 90,
angle3: float = 360,
centered: Union[bool, Tuple[bool, bool, bool]] = True,
combine: CombineMode = True,
clean: bool = True,
)
| 4019 | return self.eachpoint(lambda loc: box.moved(loc), True, combine, clean) |
| 4020 | |
| 4021 | def sphere( |
| 4022 | self: T, |
| 4023 | radius: float, |
| 4024 | direct: VectorLike = (0, 0, 1), |
| 4025 | angle1: float = -90, |
| 4026 | angle2: float = 90, |
| 4027 | angle3: float = 360, |
| 4028 | centered: Union[bool, Tuple[bool, bool, bool]] = True, |
| 4029 | combine: CombineMode = True, |
| 4030 | clean: bool = True, |
| 4031 | ) -> T: |
| 4032 | """ |
| 4033 | Returns a 3D sphere with the specified radius for each point on the stack. |
| 4034 | |
| 4035 | :param radius: The radius of the sphere |
| 4036 | :param direct: The direction axis for the creation of the sphere |
| 4037 | :type direct: A three-tuple |
| 4038 | :param angle1: The first angle to sweep the sphere arc through |
| 4039 | :type angle1: float > 0 |
| 4040 | :param angle2: The second angle to sweep the sphere arc through |
| 4041 | :type angle2: float > 0 |
| 4042 | :param angle3: The third angle to sweep the sphere arc through |
| 4043 | :type angle3: float > 0 |
| 4044 | :param centered: If True, the sphere will be centered around the reference point. If False, |
| 4045 | the corner of a bounding box around the sphere will be on the reference point and it |
| 4046 | will extend in the positive x, y and z directions. Can also use a 3-tuple to specify |
| 4047 | centering along each axis. |
| 4048 | :param combine: Whether the results should be combined with other solids on the stack |
| 4049 | (and each other) |
| 4050 | :type combine: true to combine shapes, false otherwise |
| 4051 | :param clean: call :meth:`clean` afterwards to have a clean shape |
| 4052 | :return: A sphere object for each point on the stack |
| 4053 | |
| 4054 | One sphere is created for each item on the current stack. If no items are on the stack, one |
| 4055 | box using the current workplane center is created. |
| 4056 | |
| 4057 | If combine is true, the result will be a single object on the stack. If a solid was found |
| 4058 | in the chain, the result is that solid with all spheres produced fused onto it otherwise, |
| 4059 | the result is the combination of all the produced spheres. |
| 4060 | |
| 4061 | If combine is false, the result will be a list of the spheres produced. |
| 4062 | """ |
| 4063 | |
| 4064 | # Convert the direction tuple to a vector, if needed |
| 4065 | if isinstance(direct, tuple): |
| 4066 | direct = Vector(direct) |
| 4067 | |
| 4068 | if isinstance(centered, bool): |
| 4069 | centered = (centered, centered, centered) |
| 4070 | |
| 4071 | offset = Vector() |
| 4072 | if not centered[0]: |
| 4073 | offset += Vector(radius, 0, 0) |
| 4074 | if not centered[1]: |
| 4075 | offset += Vector(0, radius, 0) |
| 4076 | if not centered[2]: |
| 4077 | offset += Vector(0, 0, radius) |
| 4078 |