Skip to main content

Create and process a part

These are complete, runnable programs that take a CAD file from upload through to a finished part. They are worth reading before you write your own, because they show the order the calls happen in and what to do while processing runs.

Both examples create the part, upload the file to the URL you get back, request processing, wait for it to finish, then get the part.

Description:

Processing does not finish while your request waits. Requesting it hands back a job immediately and the part becomes available later, which is why every example includes a step that waits for the job to complete. They wait on the job's event stream, not by asking for the job repeatedly; see Waiting for a job.

What the examples do​

Each link below goes to a small, self-contained command-line program in Toolpath's open-source examples repository. Both versions do six things:

  1. Create a part record.
  2. Upload your CAD file to the URL the API returns.
  3. Request processing for the part.
  4. Wait for the job with the SDK's waitForJob (wait_for_job in Python), which listens to the job's event stream, and show progress until processing finishes.
  5. Fetch feature details.
  6. Print the complete part as JSON.

A part holds one file. Upload before you request processing, and create a new part for a new upload: uploading again after processing has been requested is not supported, even of the same file, and the next request may be refused with 409 and the code part_source_changed. Files and tool holders work the same way, with file_source_changed and holder_source_changed.

You supply two things when you run one: your API key, read from a TOOLPATH_API_KEY environment variable, and the path to a CAD file. Nothing else needs editing. Each directory has a README with the exact commands to install and run it.

Supported CAD formats​

Neither endpoint is limited to STEP, and both accept the same list:

FormatExtensions
STEP.step, .stp
Parasolid.x_t, .x_b
SolidWorks part.sldprt
CATIA V5 part.catpart
NX / Creo part.prt
IGES.igs, .iges
Inventor part.ipt
Solid Edge part.par
ACIS.sat, .sab
Rhino.3dm

Whatever you can send to POST /v1/parts, you can send to POST /v1/holders.

Send the filename, and make its extension match

The filename query parameter on POST /v1/parts and POST /v1/holders is what tells the API which reader to use — nothing inspects the bytes you upload. It is optional, and when you omit it the upload is stored as STEP, so a SolidWorks or IGES file sent without a filename fails during processing rather than at upload. Pass the real name of the file you are about to send:

const part = await client.parts.createPart({ filename: 'bracket.sldprt' })

The file itself does not have to be named that on your disk; only the extension you pass matters.

Read the source to see how the calls fit together, or run an example as-is to confirm your key and setup work before writing any of your own code. To see the whole flow running in a full application, start from the open-source Toolpath template: its DFM app uploads a CAD part, starts analysis, follows the job's event stream, and shows the resulting features and mesh.

TypeScript​

View the TypeScript example →

Uses the @toolpath/api package, installed from npm. Its README shows the same calls in code. To show the part in a React application, see the @toolpath/viewer README.

Python​

View the Python example →

Uses the toolpath package, with its helpers to upload a part and to wait for a job; its README covers them. Install Python 3.11 or newer and uv, then follow the example's README to run it. For your own project, install the released wheel with uv as described in SDK installation; the Python SDK is distributed through GitHub Releases.