|
11 | 11 | BasePartObject, |
12 | 12 | BuildPart, |
13 | 13 | BuildSketch, |
14 | | - Location, |
| 14 | + Locations, |
15 | 15 | Mode, |
16 | 16 | Rectangle, |
17 | 17 | RotationLike, |
18 | 18 | add, |
19 | 19 | extrude, |
20 | | - fillet, |
21 | | - offset, |
22 | 20 | ) |
23 | 21 |
|
24 | 22 | from .constants import gridfinity_standard |
@@ -62,31 +60,27 @@ def __init__( |
62 | 60 |
|
63 | 61 | with BuildPart() as base: |
64 | 62 | base_block = BaseBlock(features=features, mode=Mode.PRIVATE) |
65 | | - Utils.place_by_grid(base_block, grid) |
66 | | - |
67 | | - top_face = base.faces().sort_by(Axis.Z)[-1] |
68 | | - edges = ( |
69 | | - base.edges() |
70 | | - .filter_by(Axis.Z) |
71 | | - .filter_by( |
72 | | - lambda edge: any( |
73 | | - True for vertex in edge.vertices() if vertex in top_face.vertices() |
74 | | - ), |
75 | | - ) |
| 63 | + Utils.place_by_grid( |
| 64 | + base_block, |
| 65 | + grid, |
| 66 | + width=gridfinity_standard.grid.size, |
| 67 | + length=gridfinity_standard.grid.size, |
76 | 68 | ) |
77 | | - fillet(objects=edges, radius=gridfinity_standard.grid.radius) |
78 | 69 |
|
79 | | - with BuildPart() as cutter: |
80 | | - with BuildSketch(Location((0, 0, base.part.bounding_box().max.Z))): |
81 | | - add(base.faces().sort_by(Axis.Z)[-1]) |
82 | | - offset(amount=-gridfinity_standard.grid.tollerance / 2) |
83 | | - extrude(amount=base.part.bounding_box().size.Z, dir=(0, 0, -1)) |
| 70 | + top_face_1 = base.faces().sort_by(Axis.Z)[-1] |
| 71 | + z_top = top_face_1.bounding_box().min.Z |
84 | 72 |
|
85 | | - with BuildPart() as part: |
86 | | - add(base) |
87 | | - add(cutter, mode=Mode.INTERSECT) |
| 73 | + with Locations((0, 0, z_top)): |
| 74 | + Utils.create_bin_platform( |
| 75 | + grid, |
| 76 | + align=( |
| 77 | + Align.CENTER, |
| 78 | + Align.CENTER, |
| 79 | + Align.MIN, |
| 80 | + ), |
| 81 | + ) |
88 | 82 |
|
89 | | - super().__init__(part.part, rotation, align, mode) |
| 83 | + super().__init__(base.part, rotation, align, mode) |
90 | 84 |
|
91 | 85 |
|
92 | 86 | class BaseEqual(Base): |
@@ -122,9 +116,7 @@ def __init__( |
122 | 116 | class BaseBlock(BasePartObject): |
123 | 117 | """BaseBlock. |
124 | 118 |
|
125 | | - Create a single baseblock with rectangular platform. The rectangular platform makes it |
126 | | - posible to stack the blocks in x and y direction. After creating an array it is meant to |
127 | | - cut the platform to size. |
| 119 | + Create a single baseblock. |
128 | 120 | """ |
129 | 121 |
|
130 | 122 | def __init__( |
@@ -155,14 +147,55 @@ def __init__( |
155 | 147 | gridfinity_standard.stacking_lip.offset, |
156 | 148 | ) |
157 | 149 |
|
158 | | - with BuildSketch(baseblock.faces().sort_by(Axis.Z)[-1]) as rect2: |
| 150 | + for feature in features: |
| 151 | + feature.apply(baseblock) |
| 152 | + |
| 153 | + super().__init__(baseblock.part, rotation, align, mode) |
| 154 | + |
| 155 | + |
| 156 | +class BaseBlockPlatform(BasePartObject): |
| 157 | + """BaseBlockPlatform. |
| 158 | +
|
| 159 | + Create a single baseblock with a rectangular platform on top. The rectangular platform makes it |
| 160 | + posible to stack the blocks in x and y direction. After creating an array it is meant to cut or |
| 161 | + offset the platform to size. |
| 162 | + """ |
| 163 | + |
| 164 | + def __init__( |
| 165 | + self, |
| 166 | + features: ObjectFeature | list[ObjectFeature] | None = None, |
| 167 | + rotation: RotationLike = (0, 0, 0), |
| 168 | + align: Align | tuple[Align, Align, Align] | None = None, |
| 169 | + mode: Mode = Mode.ADD, |
| 170 | + ): |
| 171 | + """Construct BaseBlockPlatform. |
| 172 | +
|
| 173 | + Args: |
| 174 | + features (ObjectFeature | list[ObjectFeature] | None, optional): ObjectFeature |
| 175 | + or list of ObjectFeatures. Defaults to None. |
| 176 | + rotation (RotationLike, optional): Angels to rotate around axes. Defaults to (0, 0, 0). |
| 177 | + align (Union[Align, tuple[Align, Align, Align]], optional): Align min center of max of |
| 178 | + object. Defaults to None. |
| 179 | + mode (Mode, optional): Combination mode. Defaults to Mode.ADD. |
| 180 | + """ |
| 181 | + if not features: |
| 182 | + features = [] |
| 183 | + |
| 184 | + features = features if isinstance(features, Iterable) else [features] |
| 185 | + |
| 186 | + base_block = BaseBlock(features=[], rotation=rotation, mode=Mode.ADD) |
| 187 | + |
| 188 | + with BuildPart() as baseblock_platform: |
| 189 | + add(base_block) |
| 190 | + |
| 191 | + with BuildSketch(baseblock_platform.faces().sort_by(Axis.Z)[-1]) as rect2: |
159 | 192 | Rectangle(gridfinity_standard.grid.size, gridfinity_standard.grid.size) |
160 | 193 | extrude( |
161 | 194 | to_extrude=rect2.sketch, |
162 | 195 | amount=gridfinity_standard.bottom.platform_height, |
163 | 196 | ) |
164 | 197 |
|
165 | 198 | for feature in features: |
166 | | - feature.apply(baseblock) |
| 199 | + feature.apply(baseblock_platform) |
167 | 200 |
|
168 | | - super().__init__(baseblock.part, rotation, align, mode) |
| 201 | + super().__init__(baseblock_platform.part, rotation, align, mode) |
0 commit comments