How to export a part (not partstudio) as a STEP file using Onshape API

mcass37
mcass37 Member Posts: 5 PRO

I'm writing a script to automate a bunch of exports and gather other part information and I was previously using the URL

"https://cad.onshape.com/api/v6/assemblies/d/{document_id}/w/{workspace_id}/e/{element_id}/translations"

but I realized after a bit that this exports the full part studio, as the URL only goes far enough to specify an element id, which would be the ID of the whole part studio the part is in. I found in the documentation a way to export parts as STL files with part ids, but cannot find any documentation or forums anywhere talking about exporting parts to STEP files. Here is the URL for exporting parts to STLs:

"https://cad.onshape.com/api/v6/parts/d/{document_id}/w/{workspace_id}/e/{element_id}/partid/{part_id}/STL?mode=text&grouping=true&scale=1&units=inch"

I tried modifying this to make it work for a STEP file and using this as the check_URL:

"https://cad.onshape.com/api/v8/translations/{request_id}"

but have had no luck. Has anybody successfully done a STEP file export via the API?

Thank you in advance!

Best Answer

  • Caden_Armstrong
    Caden_Armstrong Member Posts: 472 PRO
    Answer ✓

    If you look at the body for the partstudios translations endpoint, there is a field called: "partIds" which takes in a comma separated list of part IDs.

    https://cad.onshape.com/glassworks/explorer/#/PartStudio/createPartStudioTranslation

    www.smartbenchsoftware.com --- Renaissance --- Kestrel -- SmartLink
    Experts in Onshape Automation - Custom Features and Integrated Applications

Answers