Extracting dimension of a STEP file using phyton

Automating STEP File Analysis

Today, I tackled a challenge we’ve been facing for a long time at ST, where we specialize in thermal deburring services for a wide range of industries.

Whenever potential clients reach out to request a quote, they usually send us 3D STEP files of their components. To prepare an accurate offer, we need to evaluate the overall dimensions of each part. This is essential for calculating processing time, numbers to be deburred according to chamber size, and cost.

Here’s where the problem starts:
Our marketing colleague—who handles incoming requests—doesn’t have CAD software installed. So, every time a new file arrives, he sends it to me. I open it in my CAD environment, extract the basic dimensions, and send them back to him. This process repeats several times a week.

It’s a small task, but a recurring one that slows things down.

That’s why I decided to develop a very lightweight .exe tool that can do this job in just two clicks:

  • Load the STEP file

  • Automatically display the part’s key dimensions

In this post, I’ll walk you through how I built this simple Python-based tool that saves time, reduces back-and-forth, and lets our team respond to clients faster—even without any CAD software.

Let’s get into it:

So What This Tool Does?!

This is a lightweight GUI application designed to extract and display the X, Y, Z dimensions (bounding box) of one or multiple STEP files. It lets the user:

  • Select multiple .step files.
  • View the dimensions for each.
  • Export the results to a .csv file.
  • If needed views the part in 3d in a seperated window
  • Work within an intuitive and simple graphical interface.

Libraries and Technologies Used

Here’s a quick overview of the Python packages and libraries powering the tool:

Library Purpose
tkinter For creating the GUI (windows, buttons, listboxes, dialogs, etc.)
trimesh Lightweight geometry processing to compute bounding box dimensions
cadquery Advanced STEP file loader for solid geometry parsing
os, csv Built-in modules for file handling and exporting
tempfile Temporary file management during CAD operations

GUI Features Overview

The GUI is clean and user-friendly. Here are its main components:

  • File Selection Button: Lets you choose .step files from your PC.

  • Listbox: Displays all the selected files.

  • “Process selected” Button: Processes all listed files and shows their dimensions.

  • “Export to CSV” Button: Saves the extracted data into a CSV file.

  • “Show 3d Preview” Button: Shows the selected 3D part in a seperated window.

The interface also includes error handling and messages via popup dialogs using messagebox.


How the Code Works (Behind the Scenes)

Here’s a simplified breakdown of the code workflow:

  1. Initialize GUI App
    The class MeshProcessorApp inherits from tk.Tk and sets up the main window, title, and layout.

  2. File Selection
    When the user clicks “Add STEP Files,” a file dialog opens. The selected paths are stored and displayed in a Listbox.

  3. Extract Dimensions
    Upon clicking “Process selected” the app:

    • Uses cadquery to load each STEP file into a solid object.

    • Converts it into a mesh using trimesh.

    • Calculates the bounding box dimensions (X, Y, Z).

  4. Export to CSV
    The extracted data (filename + dimensions) is saved to a CSV file through a dialog prompt.

  5. Error Handling
    If a file fails to load or parse, an error is shown with helpful messages.

Step-by-Step: How to Use It

Here’s a quick guide for end users:

🔹 Step 1: Launch the App

Double-click the Python script (or run it from your IDE). The GUI window will appear.

🔹 Step 2: Add STEP Files

Click on “Add STEP Files” and select one or more .step files. They will be listed in the box on the left.

🔹 Step 3: Extract Dimensions

Click “Process selected”. The application will process each file and calculate its bounding box.

🔹 Step 4: Export to CSV

Click “Export to CSV” to save the results in a structured format.

Final words

This tool makes it incredibly easy for engineers, designers, and technical managers to quickly get dimensions from STEP files — no need to open bulky CAD programs. It’s also a great example of how Python and open-source libraries can be combined for practical engineering utilities.

Scroll to Top