Skip to content

MarcDuQuesne/meccano

Repository files navigation

Meccano

Meccano is a Python library for modeling and programmatically generate mechanical pieces inspired by the Meccano system, such as strips, plates, hinges, and springs. The project provides classes and utilities to create, extrude, and manage geometric and mechanical components programmatically.

Pieces can be exported to STL format for 3D printing or further processing in CAD software. The library is designed to be used with FreeCAD, a powerful open-source parametric 3D CAD modeler.

Features

  • Compatible with FreeCAD 1.0.2
  • Define and extrude custom mechanical pieces
  • Manage geometries and constraints

Supported Pieces

Hinge 1x1 Hinge 2x4x3 Flat Strip Triangle Hinge

Installation

  1. Ensure you have Python 3.11+ installed.
  2. FreeCAD must be installed and accessible in your Python environment.
  3. Insall the library using uv:
uv pip install .

Usage

Import and use the library in your Python scripts:

import FreeCAD as App

from meccano.pieces.l_shaped import Hinge

# create a new FreeCAD document
app = App.newDocument()

# Define a meccano part
hinge= Hinge(n_rows_x=2, n_columns=2, n_rows_z=2).build(app)

doc.saveAs('hinge')

Preparing the part for 3d printing

Parts or assemblies can be exported from FreeCAD in STL format using the mesh workbench, and further processed for 3d-printing. Here you see a screenshot from the CURA software: Cura Screenshot

Project Structure

  • meccano/: Core library
    • sketch_geometry.py: Geometry and measurements utilities
    • pieces/: Mechanical piece classes (e.g., FlatStrip, Plate, Hinge, Spring)
  • test/: Unit tests for the library
  • requirements.txt: Python dependencies
  • pyproject.toml: Project metadata

Testing

Run tests using pytest:

pytest

License

All code is licensed under the Apache License 2.0. See the LICENSE file for details.

About

Programmatically generate Meccano pieces in FreeCAD.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published