DXF flat-pattern export via /partstudios/.../translations fails with generic {1} failed to translate
Hi all — I'm trying to export sheet-metal flat patterns as DXF via the REST API from a Node/TypeScript backend, across many configurations of a configured Part Studio (one document, many CSV-driven configs).
Each configuration resolves to valid sheet-metal parts; in the Onshape UI, the Sheet Metal Table shows correct flat patterns. But every API translation I create enters FAILED state with a useless error.
Request
POST https://cad.onshape.com/api/v10/partstudios/d/{did}/v/{vid}/e/{eid}/translations
Body (minimal, current attempt):
{
"formatName": "DXF",
"partIds": "RkCD",
"configuration": "drop=100 mm;spouw=150 mm;blokType=c200;insertType=achter;lateiHoogte=80 mm;lateiBreedte=80 mm;lateiLengte=1500 mm;lateiDikte=4 mm;hoekRechts=90 deg;hoekLinks=90 deg;pos1=230 mm;pos2=150
mm;pos3=130 mm;pos4=750 mm;pos5=100 mm;pos6=1350 mm",
"storeInDocument": false
}
partIds is the flat-body partId — the one returned by GET /parts/d/{did}/v/{vid}/e/{eid} with isFlattenedBody: true and a name of "Flat pattern of insert achter". (I've also tried the 3D sheet-metal partId
from that body's unflattenedPartId.)
Polled translation response
{
"requestState": "FAILED",
"requestElementId": "f136f91fabbffad75c5de577",
"resultExternalDataIds": null,
"versionId": "e93e7309c5476853f18873b3",
"documentId": "14d1a61059b47387f9583232",
"failureReason": "<a class=os-import-filename href='69e77e17983e0e294d03e906'>{1}</a> failed to translate.",
"name": "GD Master - Flat pattern of insert achter",
"id": "69e77e15983e0e294d03e8ff"
}
The failureReason is clearly a broken HTML template — the {1} placeholder is never substituted. name is set correctly, so Onshape identified the right part; the translation process itself is what's failing.
What I've already tried
Variant | Endpoint | Payload aanpassingen | Resultaat |
|---|---|---|---|
1 |
|
| Foutmelding: 'failed to translate' |
2 |
|
| Zelfde fout |
3 |
|
| Zelfde fout |
4 |
|
| Zelfde fout |
5 |
|
| Zelfde fout |
6 |
| Willekeurige body | 404 Not Found |
The same Part Studio + configuration, manually exported from the Onshape UI (right-click flat view → Export → DXF), produces a correct DXF. So the part itself is fine.
Hypothesis
Forum thread https://forum.onshape.com/discussion/24791 mentions DXF export requires specifying "which face to export" via a face ID — matching the UI flow that asks you to pick a planar face. None of the
community payload examples I've found include a face-ID field, and the BTTranslateFormatParams schema is not documented in the OpenAPI spec I can pull from /api/openapi.
Questions
- What is the correct request body for POST /partstudios/.../translations when the format is DXF for a sheet-metal flat pattern? Specifically, is there a required faceId / flatPatternFaceId / passedFaceIds
/ similar field, and what's the exact name? - Should partIds be the flat-body id or the 3D part id? If it's the 3D part, what flag triggers the flatten-before-export behavior server-side?
- Is there a dedicated endpoint for sheet-metal DXF export I'm missing (the gltf/obj/step part-studio export endpoints are documented but there's nothing equivalent for DXF)?
- Is configuration in the JSON body expected raw or percent-encoded?
A working cURL or Python snippet for a configured sheet-metal part would unblock me entirely. Happy to share the failing translation IDs privately with staff for debugging.
Thanks!
Comments
-
This is a snippet of the python code I wrote a very long time ago to download sheetmetal flat pattern dxf. which still works for us
body = {
"format": "DXF",
"view": "1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1",
"destinationName": "ignored.dxf",
"version": "2007",
"flatten": False, # just copy what web sends
"includeBendCenterlines": True,
"includeCboreCsink": True,
"includeSketches": True,
"sheetMetalFlat": True,
"units": "millimeter",
"triggerAutoDownload": True,
"storeInDocument": False,
"configuration": "default",
"partIds": flat_id,
}
if f.cfg and f.cfg != "default":
body["configuration"] = f.cfg
endpoint = f"/api/documents/d/{f.did}/{f.wvm}/{f.wvmid}/e/{f.eid}/export"
dest = f"{self.credentials['stack']}{endpoint}"
# Stage 1, request export translation to DXF
response = self.conn.post_request(dest, body)
if response.status_code not in (200, 202):
raise OnshapeInterfaceError(
f"Export flat pattern DXF failed {response.status_code}"
)The partId is the partId of the flattened body and I got it from calling:
/api/parts/d/{f.did}/{f.wvm}/{f.wvmid}/e/{f.eid}}?includeFlatParts=trueand filtering the results by checking for isFlattenedBody being true.
Remember once it works you get back a translation id that you then need to poll until it is complete to actually download the dxf itself.
1 -
Hey, thanks for this!
Once you shared your code, we immediately spotted three things we were getting wrong:
- Wrong endpoint. We were using the modern v10 /partstudios/.../translations endpoint. Your code used the legacy /documents/.../export endpoint. These behave completely differently and the v10 one just
doesn't work reliably for flat pattern exports. - Wrong payload field. We had formatName: 'DXF'. The legacy export endpoint expects format: 'DXF'. Small difference, big consequence.
- Wrong polling path. The export endpoint returns a modelexport URL like https://cad-euw1.onshape.com/modelexport/exportresults/{id}?_m=.... We were extracting that ID and polling /api/v10/translations/{id}
, which returns 404. The correct path is the legacy /api/translations/{id} (no v10). Translations created via the legacy export endpoint are only accessible via the legacy API.
Once all three were fixed, it worked first try. Files came back on the very first poll attempt (~3 seconds), proper DXF content, no empty files.
Thanks again,
Luk0 - Wrong endpoint. We were using the modern v10 /partstudios/.../translations endpoint. Your code used the legacy /documents/.../export endpoint. These behave completely differently and the v10 one just
Categories
- All Categories
- 10.2K Community Support
- 4.6K General
- 194 Account and subscriptions
- 353 Data management
- 1.6K Product Feedback
- 215 New in Onshape
- 14 Onshape Labs
- 75 CAM Studio
- 35 PCB Studio
- 107 Simulation
- 209 Onshape Mobile
- 315 App Store & Partners Apps
- 8.2K Using Onshape
- 1.8K Drawings
- 2.3K FeatureScript
- 324 Learning Center
- 253 Education Community
