How to Stop Items Being Rotated During Packing
A drum of solvent does not care how good your fill percentage is. Tip it on its side and the plan is scrap — regardless of what the solver thinks it saved. The same goes for electronics with a defined “this way up”, for anything with a liquid headspace, and for cargo whose packaging only takes load on its base.
Most 3D bin packing output looks perfectly reasonable until you notice that half the upright-only items are lying down. That is not a bug in the maths; it is a missing constraint. Free rotation is the default in packing because it buys fill percentage, and a solver with no orientation input will happily use it.
This article is the fix: mark the items that must stay upright in RSJ 3D Packer, re-solve, and confirm from the returned plan that the flagged items are still standing. You will see both the API route ("vertical": false) and the browser equivalent, because the constraint is the same field in both.
One thing worth stating up front: this is a per-item setting, not a global switch. A container can carry upright-only drums and freely rotatable cartons in the same solve, and the solver keeps full freedom on the cartons.
Why rotation control matters (and what you’ll achieve)
In a 3D bin packing problem, every item and every container has its own width, height and depth, mapped to x/y/z. An item that may be rotated can be placed in any orientation that fits; an item marked upright-only may only be placed the way it was defined, standing on its base.
Why does that matter beyond the obvious?
- Liquids and batteries must not be inverted or laid down.
- Fill percentage becomes trustworthy. A plan that hits 82% by tipping your cargo is worse than a plan that hits 71% with everything the right way up.
- The constraint costs something, and you should see that cost. Upright-only cargo usually reduces achievable fill. That is expected, and the plan reports it per container.
By the end of this walkthrough you will have:
- Marked your upright-only items in the request.
- Solved the problem within the 240-second solver budget.
- Verified in the 3D viewer and in the JSON that those items kept their orientation — and seen what happens to the ones that could not be placed.
Prerequisites
Before you start, have these ready:
- An RSJ 3D Packer account. The free 30-day test exposes the Pro feature set, which includes preventing vertical rotation, so you can try this before choosing a plan.
- Item dimensions — width, height and depth for every item.
countdefaults to one if you omit it. - Container dimensions — width, height and depth, plus how many containers you want available.
- The right plan for production use. Preventing vertical rotation is available on Standard and Pro, not on Basic.
- Optional, for automation: the API reference, the OpenAPI specification and the API sandbox — a live request/response playground with a 3D preview.
The API is a JSON REST interface at https://3dpacker.rsj.de. Calls need a session token in an Authorization: Bearer … header; you obtain one from GET /user/{email}?hmac={hmac} and it stays valid for roughly a day, so fetch a fresh one rather than storing it. If you are working in the browser application, cookies handle this for you.
Step-by-step: mark upright-only items and solve
Step 1 — Open the packing application and set up the problem
Go to the packing application and start a new problem, or load the item list you already maintain. If you are solving programmatically, keep the reference and sandbox tabs open — the sandbox lets you paste a request body and see both the JSON response and the 3D result without writing a client.
Step 2 — Set vertical: false on every item that must stay upright
This is the whole trick. In the API it is a single boolean on the item. In the browser application it is the equivalent upright-only toggle on that item’s row.
{
"containers": [
{ "width": 120, "height": 110, "depth": 100, "count": 2 }
],
"items": [
{
"id": 0,
"width": 11, "height": 6, "depth": 6,
"count": 51
},
{
"id": 1,
"width": 7, "height": 8, "depth": 9,
"count": 53,
"vertical": false,
"itemClass": 1,
"weight": 12
}
]
}
Item 1 may not be rotated out of its upright position. Item 0 says nothing about orientation, so it stays free.
The optional id is yours to choose and is echoed back on packed and unpacked items. Set it deliberately — it is what makes the verification in the next section a one-line lookup instead of a guessing game.
Step 3 — Leave vertical unset on items that may rotate
Do not set vertical: false out of caution on the whole request. Every item you pin upright removes orientations from the search space, and fill percentage pays for it. Mark the drums, the battery packs, the sealed electronics — leave the cartons, the bags and the palletised flat goods free.
Step 4 — Add containers, and weight limits if your plan includes them
Containers take width, height, depth and count. On Standard and Pro you can also set weight as a maximum load, which is enforced alongside orientation. If your load mixes goods that must not sit on top of each other, note that stacking classes interact with orientation: an item is only ever placed on items of a lower or equal class, and a pinned-upright item at a high class can shrink the usable volume more than the flag alone suggests.
Step 5 — Submit the solve request
curl -s https://3dpacker.rsj.de/solve \
-H "Authorization: Bearer $SESSION" \
-H "Content-Type: application/json" \
-d @problem.json \
-o plan.json
The solver works within a 240-second time budget per request, on every plan. Give your HTTP client a timeout slightly above that so you do not cut a slow solve short. In Python:
import requests
SESSION = "session-…" # from GET /user/{email}?hmac={hmac}
problem = {
"containers": [{"width": 120, "height": 110, "depth": 100, "count": 2}],
"items": [
{"id": 1, "width": 7, "height": 8, "depth": 9, "count": 53,
"vertical": False, "itemClass": 1, "weight": 12},
{"id": 2, "width": 7, "height": 8, "depth": 9, "count": 53},
],
}
response = requests.post(
"https://3dpacker.rsj.de/solve",
json=problem,
headers={"Authorization": f"Bearer {SESSION}"},
timeout=260,
)
response.raise_for_status()
plan = response.json()
The response gives you packed items with a container index and x/y/z position, fill percentage per container, the number of containers used, unpacked items with counts, plus a viewer URL and an API sandbox URL.
Step 6 — Inspect the orientation in the viewer or the raw response
Open the viewer URL from the response, or embed the viewer in an IFRAME if you are surfacing results inside your own tooling. Item 1 should be standing with its 8-unit dimension vertical, at every position it appears in.
If you would rather diff the numbers, the plan is plain JSON:
jq '[.packedItems[] | select(.id == 1)] | .[0:3]' plan.json
[
{ "id": 1, "c": 0, "width": 7, "height": 8, "depth": 9, "x": 0, "y": 0, "z": 0 },
{ "id": 1, "c": 0, "width": 7, "height": 8, "depth": 9, "x": 7, "y": 0, "z": 0 }
]
You could hand-code orientation constraints into a custom solver. RSJ 3D Packer exposes the same thing as one field per item, so that is the hard way and not a required one.
How to confirm the rotation constraint was respected
Four checks, in increasing order of strictness:
1. The 3D view. Flagged items should have their height axis aligned with the container’s y-axis. Nothing tipped. This is the fastest check and the one to show a colleague who does not read JSON.
2. Dimension comparison in packedItems. For each packed entry whose source item had "vertical": false, confirm the height value still matches the height you submitted. A rotation around the vertical axis keeps an item upright, so a width/depth swap is not on its own a violation — what must never happen is your submitted height turning up in the width or depth slot.
by_id = {item["id"]: item for item in problem["items"]}
for packed in plan["packedItems"]:
source = by_id[packed["id"]]
if source.get("vertical", True) is False:
assert packed["height"] == source["height"], (
f"item {packed['id']} was tipped at "
f"({packed['x']}, {packed['y']}, {packed['z']})"
)
3. unpackedItems. If an upright-only item could not be placed within the container dimensions and the other constraints, it appears here with a count — it is left out, not forced in sideways. That is the correct behaviour and the honest answer.
4. Fill percentage per container. Compare a run with the flag against one without. The gap is the real cost of keeping cargo upright, and it is the number you take to whoever asked why the container is not full.
Downloading the solution as a GLB 3D model is a convenient way to hand the geometry to someone who wants to inspect it outside the browser.
Troubleshooting common issues
- An item still appears rotated. Check that
vertical: falsesits on the right item — with counts and similar dimensions, off-by-one onidis the usual culprit. Then check your plan: Basic does not include rotation control, so the flag has no effect there. - Most upright-only items land in
unpackedItems. The constraint plus your container height may make the load infeasible. Either the item is too tall for the container when standing, or the pinned items leave no supported footprint. Try more containers, review dimensions, or split the upright-only cargo across containers. - A mixed load behaves unexpectedly. Remember stacking classes: an item is only placed on items of a lower or equal class. A tall upright item at class 1 becomes a platform nothing above class 1 can sit on, which can strand volume that looked free.
- The API returns an error. Verify that
width,heightanddepthare present on every item and every container, and thatcountis a positive integer.itemClassand risk types are integers;weight,riskPointsandallowedRiskPointsare numbers. Unknown keys are ignored, so extra client metadata travels along harmlessly — but avoid names that could collide with future fields. - Nothing is placed at all. Check that
itemsandcontainersare both present;risksis optional and not the cause here.
FAQ
Can I prevent rotation for only some items in a load?
Yes. The vertical flag is set per item. Set "vertical": false on the items that must stay upright and leave it unset on items that may be rotated freely, so the solver keeps full freedom where it helps.
Does marking an item upright-only guarantee it will be packed?
No. The solver respects the orientation constraint, but if an upright-only item cannot be placed within the container dimensions and other constraints, it will appear in unpackedItems with a remaining count rather than being forced in sideways.
What happens if an upright-only item cannot fit?
It is reported in the unpackedItems list of the response with its count, so you can see exactly what was left out and adjust container sizes or quantities.
Is there a way to do this without the API?
Yes. The web application at https://3dpacker.rsj.de/ lets you set the upright-only option per item in the browser and view the result in an interactive 3D view; the API is optional for automation.
Conclusion
Keeping liquids, batteries and electronics the right way up is one field: "vertical": false on the items that must not be rotated, left off everything else. The solver takes that constraint into account, keeps the plan free of floating items, and tells you honestly — through unpackedItems — when an upright item did not fit.
The free 30-day test exposes the Pro feature set, so you can check the fill-percentage cost of upright-only cargo on your own load before committing to Standard or Pro. Start in the browser application, then replay the same request in the API sandbox once you want to automate it, and look at the plans page when you are ready to subscribe.
Related posts
- Dangerous Goods Segregation in Container Packing: What a Plan Must Respect
- Automate Container Loading Plans Straight From Google Sheets
- Packing Optimisation API for Developers: What to Check