REST API - Exporting a part to STEP works, but exporting to DXF does not

guillauem_d
guillauem_d Member Posts: 20 ✭✭
Hello there !  :D

I'm trying to export my sheet metal part using the REST API, exporting it to a STEP file works fine using the following method : 
  • Initiate the exporting procedure using /api/v6/assemblies/d/{}/w/{}/e/{}/translations and inputing STEP as formatName
  • Wait for the /api/v8/translations/{requestId}  requestState to be DONE
  • Download the STEP using /api/v8/translations/{requestId}
The problem is that exporting to a DXF using the same method doesn't work, I know that it's probably because i'm not telling the code which face to export (just like I would manually), but I don't know how do input that.
Where should i plug the face ID ? Here is my working code for STEP files : 

payload = {
    "allowFaultyParts": True,
    "angularTolerance": 0.001,
    "formatName": "STEP",
    "storeInDocument": True,
}

response = requests.post(
        DID, WID, EID
    ),
    auth=(API_ACCESS, API_SECRET),
    headers={
        "Accept": "application/json;charset=UTF-8; qs=0.09",
        "Content-Type": "application/json",
    },
    json=payload
)

What changes should I make to make it work with DXF ?

Thank you in advance !  :)

Answers

  • Kevin_Vaidyan
    Kevin_Vaidyan Member Posts: 2 ✭

    I managed to get it to work, directly message me if help is required.

    You cannot just list all parts and try to export them, non-sheet-metal parts will return 4xx. You need to identify flat patterns specifically using the insertables endpoint with includeFlattenedBodies=true:

    Use deterministicId (from insertables), not partId (from the parts list). Export endpoints are keyed on deterministicId.

    For the actual export step, use the official translations API (POST /api/v6/partstudios/d/{did}/w/{wid}/e/{eid}/translations with formatName: "DXF"). It's async — fire the job, poll /api/v6/translations/{jobId} until requestState === "DONE", then fetch the blob from resultExternalDataIds[0].