{
  "id": 17022795,
  "title": "Fitting Three Objects in One Case: Modeling Multi-Item Packaging",
  "url": "https://urgent.news/2026/10/29/fitting-three-objects-in-one-case-modeling-multi-item-packaging",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-29T06:54:17.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/tancy1688/fitting-three-objects-in-one-case-modeling-multi-item-packaging-17ab"
  },
  "original_language": "en",
  "account": "In the third installment of the series, the focus shifts to a case designed to hold multiple objects with varying shapes and sizes. Previously, the model worked well for a single item, but adding multiple items with diverse dimensions and tolerances proves to be a challenge.\n\nThe previous model only had one dimensions block and one interiorProfile, which is insufficient for a multi-item set. Instead, the interior is now represented as a layout, with each item having its own cavity. Initially, a naive fix was to add separate fields for each cavity, such as bottleCavity and fluteCavityLeft. However, this approach becomes inadequate when the client requests changes, like adding more glasses or altering the bottle size.\n\nA more robust solution is to model cavities as a list, allowing for flexibility in handling various configurations. The new data structure includes type Cavity with properties like id, holds, inner dimensions, clearance, position, and orientation. The MultiItemSpec type combines the envelope dimensions, wall thickness, list of cavities, and shared tolerance.\n\nThe crucial constraint to consider is the additive nature of the fit check. While a single item is only verified by checking if it fits within the envelope, multiple items require a more complex calculation. The sum of the cavity widths, plus dividers and double the wall thickness, must be less than or equal to the envelope width.\n\nTo enforce this constraint, a validator function is implemented. It calculates the total cavity width by adding each cavity's width and clearance, then determines the required width based on the number of cavities and wall thickness. If the required width exceeds the envelope width, an error message is generated, indicating the shortfall in millimeters.\n\nThe error message is the most valuable aspect of the validator, as it provides clear feedback on the issue without merely returning a boolean value. This feedback enables swift resolution of the problem, preventing lengthy email threads and delays in the supply chain.\n\nThe key takeaway from this series is the importance of structuring packaging specifications effectively. By keeping shared fields centralized and leveraging lists for variable aspects like cavities, the design becomes adaptable to different configurations. Moreover, validating the additive constraint and providing informative error messages ensures that packaging designs meet the required specifications and function as intended.",
  "summary": "The first article in this series modeled a product as a data model. The second one dealt with a curved object that broke the rectangular assumption. This one is worse: a case that holds three objects — one bottle, two champagne flutes — each with a different shape, a different tolerance, and its own cavity. And they all have to share one outer envelope. Here is what that does to the schema. The…",
  "key_points": [
    "Multi-item packaging case now uses layout with individual cavities for each object.",
    "Cavity data structure includes id, inner dimensions, clearance, position, and orientation."
  ],
  "editors_take": "Transitioning from single-item fields to a list-based data structure allows packaging designs to scale dynamically while preventing supply chain delays through automated, descriptive validation of spatial constraints.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}