11"""Module containing gridfinity feature constructions."""
22
3+ from __future__ import annotations
4+
35import math
46from typing import Literal
57
@@ -187,8 +189,24 @@ def scoop_properties(obj: fc.DocumentObject, *, scoop_default: bool) -> None:
187189 ).Scoop = scoop_default
188190
189191
190- def make_scoop (obj : fc .DocumentObject ) -> Part .Shape :
191- """Create scoop."""
192+ def make_scoop (
193+ obj : fc .DocumentObject ,
194+ * ,
195+ usable_height : None | fc .Units .Quantity = None ,
196+ ) -> Part .Shape :
197+ """Create scoop.
198+
199+ Args:
200+ obj: The object onto which to add the scoop.
201+ usable_height: Override the obj's UsableHeight value (for EcoBins).
202+
203+ EcoBins are constructed in such a way that when the scoop is added, the
204+ proper usable height (for correct geometry) has to be provided separately.
205+
206+ """
207+ if usable_height is None :
208+ usable_height = obj .UsableHeight
209+
192210 scooprad1 = obj .ScoopRadius + unitmm
193211 scooprad2 = obj .ScoopRadius + unitmm
194212 scooprad3 = obj .ScoopRadius + unitmm
@@ -203,8 +221,8 @@ def make_scoop(obj: fc.DocumentObject) -> Part.Shape:
203221 scooprad1 = xdivscoop - unitmm
204222 if obj .ScoopRadius > xcomp_w and obj .xDividers > 0 :
205223 scooprad2 = xcomp_w - 2 * unitmm
206- if obj .ScoopRadius > obj . UsableHeight > 0 :
207- scooprad3 = obj . UsableHeight - obj .LabelShelfStackingOffset
224+ if obj .ScoopRadius > usable_height > 0 :
225+ scooprad3 = usable_height - obj .LabelShelfStackingOffset
208226
209227 scooprad = min (obj .ScoopRadius , scooprad1 , scooprad2 , scooprad3 )
210228
@@ -214,17 +232,17 @@ def make_scoop(obj: fc.DocumentObject) -> Part.Shape:
214232 v1 = fc .Vector (
215233 obj .xTotalWidth + obj .Clearance - obj .WallThickness ,
216234 0 ,
217- - obj . UsableHeight + scooprad ,
235+ - usable_height + scooprad ,
218236 )
219237 v2 = fc .Vector (
220238 obj .xTotalWidth + obj .Clearance - obj .WallThickness ,
221239 0 ,
222- - obj . UsableHeight ,
240+ - usable_height , # type: ignore[arg-type]
223241 )
224242 v3 = fc .Vector (
225243 obj .xTotalWidth + obj .Clearance - obj .WallThickness - scooprad ,
226244 0 ,
227- - obj . UsableHeight ,
245+ - usable_height , # type: ignore[arg-type]
228246 )
229247
230248 l1 = Part .LineSegment (v1 , v2 )
@@ -237,7 +255,7 @@ def make_scoop(obj: fc.DocumentObject) -> Part.Shape:
237255 - scooprad
238256 + scooprad * math .sin (math .pi / 4 ),
239257 0 ,
240- - obj . UsableHeight + scooprad - scooprad * math .sin (math .pi / 4 ),
258+ - usable_height + scooprad - scooprad * math .sin (math .pi / 4 ),
241259 )
242260
243261 c1 = Part .Arc (v1 , vc1 , v3 )
@@ -268,7 +286,7 @@ def make_scoop(obj: fc.DocumentObject) -> Part.Shape:
268286 scoopbox = Part .makeBox (
269287 stacking_lip_offset .Value ,
270288 obj .yTotalWidth - obj .WallThickness * 2 ,
271- obj . UsableHeight ,
289+ usable_height , # type: ignore[arg-type]
272290 fc .Vector (
273291 obj .xTotalWidth + obj .Clearance - obj .WallThickness ,
274292 obj .Clearance + obj .WallThickness ,
@@ -280,7 +298,7 @@ def make_scoop(obj: fc.DocumentObject) -> Part.Shape:
280298 edges = [
281299 edge
282300 for edge in funcfuse .Edges
283- if abs (edge .Vertexes [0 ].Z - edge .Vertexes [1 ].Z ) == obj . UsableHeight
301+ if abs (edge .Vertexes [0 ].Z - edge .Vertexes [1 ].Z ) == usable_height
284302 and edge .Vertexes [0 ].X == edge .Vertexes [1 ].X
285303 ]
286304
0 commit comments