This project is a Python-based tool for working with 3D geometry in STEP files using CadQuery. It allows users to define a plane in point-normal form, check for intersections with geometries in a STEP file, and export intersection points to a new STEP file.
- Read and process STEP files
- Define planes using point-normal form
- Check for intersections between the plane and geometries in the STEP file
- Export intersections to a new STEP file if found
Ensure Homebrew is installed.
-
Install Python, and OpenCascade:
brew install python brew install opencascade
-
Install
uvpackage manager:curl -LsSf https://astral.sh/uv/install.sh | sh -
Create a virtual environment and install dependencies:
uv venv uv sync
-
Run the Program
uv run main.py --in-step <STEP_FILE_PATH> --in-plane x y z nx ny nz
- Replace
<STEP_FILE_PATH>with the path to your STEP file. - Replace
x, y, z, nx, ny, and nzwith the point and normal vector of the plane, space-separated e.g.:python main.py --in-step random-shape.stp --in-plane 0 0 100 0.2 0.1 1.0
- Replace
-
Outputs
- If intersections are found, they are written to
intersection.stpin the project directory. - If no intersections are found, no new STEP file is created, and a message informs you accordingly.
- If intersections are found, they are written to
stp_cli/
├── README.md # Documentation
├── requirements.txt # Project dependencies
├── main.py # Main entry point
├── src/ # Source code
│ ├── __init__.py
│ ├── exceptions.py # custom exceptions
│ ├── domain/ # data structures
│ │ ├── __init__.py
│ │ └── model.py
│ ├── fileio/ # io functions
│ │ ├── __init__.py
│ │ ├── reader.py
│ │ └── writer.py
│ └── geometry/ # 3D processing
│ ├── __init__.py
│ └── engine.py
│
└── tests/ # Tests
├── __init__.py
├── conftest.py # Fixtures
├── unit/ # Unit tests
│ ├── __init__.py
│ ├── test_fileio.py
│ ├── test_model.py
│ └── test_plane.py
└── integration/ # Integration tests
├── __init__.py
└── test_workflow.py
Run the test suite using pytest:
uv run pytest- File Reading Tests:
- Check if the STEP file is correctly read
- Validate error handling for non-existent or invalid files
- Intersection Tests:
- Verify that intersections are detected and written to the output STEP file
- Ensure no output file is created when no intersections are found
- CadQuery
- Python 3.11+
uvpackage manager
- The tool assumes valid STEP files as input; invalid or malformed files may cause unexpected errors.
- Intersection detection depends on the geometric complexity of the input model.