Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

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

guillauem_dguillauem_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_VaidyanKevin_Vaidyan Member Posts: 2 PRO

    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].

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.