Skip to content

ninnlangel/FreeCadScripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FreeCAD Scripts

A collection of Python scripts for FreeCAD to generate 3D-printable objects.

Scripts

Keyring Tag Generator (keyring_tag.py)

Generates customizable rounded-rectangle keyring tags that automatically adapt their length to fit your text. Perfect for creating personalized keyrings via 3D printing.

Features:

  • Auto-sizing tag length based on text width
  • Rounded corners for printing
  • Built-in hole for key rings
  • Exports to 3MF format for slicing and printing
  • Batch processing support
  • Works in both CLI (headless) and GUI (macro) modes

Usage

Headless mode (CLI):

Using the keytag shell wrapper (Linux/macOS):

# Single tag
./keytag "MyText"

# Custom output file
./keytag "MyText" custom_output.3mf

# Batch processing
for text in Alice Bob Charlie; do
  ./keytag "$text"
done

Or directly with freecadcmd:

# Single tag
TAG="MyText" freecadcmd keyring_tag.py

# Custom output file
TAG="MyText" OUT="custom_output.3mf" freecadcmd keyring_tag.py

GUI Macro mode:

  1. Open FreeCAD
  2. Edit TAG_TEXT variable in the script to your desired text
  3. Go to Macro → Execute Macro and select this file
  4. The output will be saved to ./keyrings/tag.3mf

Customization

Edit these variables in the script to adjust dimensions:

MIN_TAG_LENGTH = 30.0     # Minimum tag length in mm
TAG_WIDTH = 12.0          # Tag width in mm
TAG_THICK = 1.6           # Tag thickness in mm
CORNER_R = 3.0            # Rounded corner radius in mm
HOLE_DIA = 4.0            # Key ring hole diameter in mm
TEXT_SIZE = 6.0           # Font size in mm

Requirements

  • FreeCAD with Python 3 support (tested with FreeCAD 0.19+)

  • Font files: One of the following fonts must be installed:

    • DejaVu Sans (recommended) - usually pre-installed on Linux
    • Liberation Sans
    • Free Sans
    • Arial / Helvetica (macOS/Windows)

    Most Linux distributions include DejaVu fonts by default. On macOS and Windows, system fonts are typically available.

Directory Structure

The script creates output files in the following structure:

FreeCadScripts/
├── keyring_tag.py          (this script)
├── keyrings/               (auto-created, contains output .3mf files)
│   ├── mytext.3mf
│   └── ...
└── README.md

Output files are created in the keyrings/ subdirectory relative to the script's location.

Environment Variables

  • TAG - Text to display on the tag (default: "TAG")
  • OUT - Output file path (default: auto-generated from tag text)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Feel free to fork, modify, and submit pull requests.

System Requirements

  • FreeCAD
  • Python 3.6+

About

A set of scripts to generate objects to 3d print

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors