@@ -124,28 +124,60 @@ def createGridfinityBinBody(
124124 for compartment in input .compartments :
125125 compartmentX = compartmentsMinX + compartment .positionX * (compartmentWidthUnit + input .wallThickness )
126126 compartmentY = compartmentsMinY + compartment .positionY * (compartmentLengthUnit + input .wallThickness )
127+ compartmentOriginPoint = adsk .core .Point3D .create (
128+ compartmentX ,
129+ compartmentY ,
130+ binBodyTotalHeight
131+ )
132+ compartmentWidth = compartmentWidthUnit * compartment .width + (compartment .width - 1 ) * input .wallThickness
133+ compartmentLength = compartmentLengthUnit * compartment .length + (compartment .length - 1 ) * input .wallThickness
134+ compartmentDepth = min (binBodyTotalHeight - const .BIN_COMPARTMENT_BOTTOM_THICKNESS , compartment .depth )
135+
136+ compartmentTabInput = BinBodyTabGeneratorInput ()
137+ tabOriginPoint = adsk .core .Point3D .create (
138+ compartmentOriginPoint .x + max (0 , min (input .tabPosition , input .binWidth - input .tabLength )) * input .baseWidth ,
139+ compartmentOriginPoint .y + compartmentLength ,
140+ compartmentOriginPoint .z ,
141+ )
142+ compartmentTabInput .origin = tabOriginPoint
143+ compartmentTabInput .length = max (0 , min (input .tabLength , input .binWidth )) * input .baseWidth
144+ compartmentTabInput .width = input .tabWidth
145+ compartmentTabInput .overhangAngle = input .tabOverhangAngle
146+ compartmentTabInput .topClearance = const .BIN_TAB_TOP_CLEARANCE
147+
127148 [compartmentMerges , compartmentCuts ] = createCompartment (
128149 input .wallThickness ,
129- adsk .core .Point3D .create (
130- compartmentX ,
131- compartmentY ,
132- binBodyTotalHeight
133- ),
134- compartmentWidthUnit * compartment .width + (compartment .width - 1 ) * input .wallThickness ,
135- compartmentLengthUnit * compartment .length + (compartment .length - 1 ) * input .wallThickness ,
136- min (binBodyTotalHeight - const .BIN_COMPARTMENT_BOTTOM_THICKNESS , compartment .depth ),
150+ compartmentOriginPoint ,
151+ compartmentWidth ,
152+ compartmentLength ,
153+ compartmentDepth ,
137154 input .hasScoop ,
138155 input .scoopMaxRadius ,
139156 input .hasTab ,
140- max (0 , min (input .tabLength , input .binWidth )) * input .baseWidth ,
141- input .tabWidth ,
142- max (0 , min (input .tabPosition , input .binWidth - input .tabLength )) * input .baseWidth ,
143- input .tabOverhangAngle ,
157+ compartmentTabInput ,
144158 targetComponent ,
145159 )
146160 bodiesToSubtract = bodiesToSubtract + compartmentCuts
147161 bodiesToMerge = bodiesToMerge + compartmentMerges
148162
163+ if len (input .compartments ) > 1 :
164+ compartmentsTopClearance = createCompartmentCutout (
165+ input .wallThickness ,
166+ adsk .core .Point3D .create (
167+ compartmentsMinX ,
168+ compartmentsMinY ,
169+ binBodyTotalHeight
170+ ),
171+ actualBodyWidth - input .wallThickness * 2 ,
172+ actualBodyLength - input .wallThickness * 2 ,
173+ const .BIN_TAB_TOP_CLEARANCE ,
174+ False ,
175+ 0 ,
176+ False ,
177+ targetComponent ,
178+ )
179+ bodiesToSubtract .append (compartmentsTopClearance )
180+
149181 if len (bodiesToSubtract ) > 0 :
150182 combineUtils .cutBody (
151183 binBody ,
@@ -162,24 +194,18 @@ def createGridfinityBinBody(
162194 return binBody
163195
164196
165- def createCompartment (
197+ def createCompartmentCutout (
166198 wallThickness : float ,
167199 originPoint : adsk .core .Point3D ,
168200 width : float ,
169201 length : float ,
170202 depth : float ,
171203 hasScoop : bool ,
172204 scoopMaxRadius : float ,
173- hasTab : bool ,
174- tabLength : float ,
175- tabWidth : float ,
176- tabPosition : float ,
177- tabOverhangAngle : float ,
205+ hasBottomFillet : bool ,
178206 targetComponent : adsk .fusion .Component ,
179- ) -> tuple [ list [ adsk .fusion .BRepBody ], list [ adsk . fusion . BRepBody ]] :
207+ ) -> adsk .fusion .BRepBody :
180208
181- bodiesToMerge : list [adsk .fusion .BRepBody ] = []
182- bodiesToSubtract : list [adsk .fusion .BRepBody ] = []
183209 innerCutoutFilletRadius = max (const .BIN_BODY_CUTOUT_BOTTOM_FILLET_RADIUS , const .BIN_CORNER_FILLET_RADIUS - wallThickness )
184210 innerCutoutInput = BinBodyCutoutGeneratorInput ()
185211 innerCutoutInput .origin = originPoint
@@ -188,28 +214,42 @@ def createCompartment(
188214 innerCutoutInput .height = depth
189215 innerCutoutInput .hasScoop = hasScoop
190216 innerCutoutInput .scoopMaxRadius = scoopMaxRadius
191- innerCutoutInput .hasTab = hasTab
192- innerCutoutInput .tabLength = tabLength
193- innerCutoutInput .tabWidth = tabWidth
194- innerCutoutInput .tabPosition = tabPosition
195- innerCutoutInput .tabOverhangAngle = tabOverhangAngle
196217 innerCutoutInput .filletRadius = innerCutoutFilletRadius
218+ innerCutoutInput .hasBottomFillet = hasBottomFillet
197219
198- innerCutoutBody = createGridfinityBinBodyCutout (innerCutoutInput , targetComponent )
220+ return createGridfinityBinBodyCutout (innerCutoutInput , targetComponent )
221+
222+ def createCompartment (
223+ wallThickness : float ,
224+ originPoint : adsk .core .Point3D ,
225+ width : float ,
226+ length : float ,
227+ depth : float ,
228+ hasScoop : bool ,
229+ scoopMaxRadius : float ,
230+ hasTab : bool ,
231+ tabInput : BinBodyTabGeneratorInput ,
232+ targetComponent : adsk .fusion .Component ,
233+ ) -> tuple [list [adsk .fusion .BRepBody ], list [adsk .fusion .BRepBody ]]:
234+
235+ bodiesToMerge : list [adsk .fusion .BRepBody ] = []
236+ bodiesToSubtract : list [adsk .fusion .BRepBody ] = []
237+
238+ innerCutoutBody = createCompartmentCutout (
239+ wallThickness ,
240+ originPoint ,
241+ width ,
242+ length ,
243+ depth ,
244+ hasScoop ,
245+ scoopMaxRadius ,
246+ True ,
247+ targetComponent ,
248+ )
199249 bodiesToSubtract .append (innerCutoutBody )
200250
201251 # label tab
202252 if hasTab :
203- tabInput = BinBodyTabGeneratorInput ()
204- tabOriginPoint = adsk .core .Point3D .create (
205- originPoint .x + tabPosition ,
206- originPoint .y + length ,
207- innerCutoutInput .origin .z ,
208- )
209- tabInput .origin = tabOriginPoint
210- tabInput .length = tabLength
211- tabInput .width = tabWidth
212- tabInput .overhangAngle = tabOverhangAngle
213253 tabBody = createGridfinityBinBodyTab (tabInput ,targetComponent )
214254
215255 intersectTabInput = targetComponent .features .combineFeatures .createInput (
0 commit comments