Skip to main content

Python library for automated DXF file marking and manipulation to engrave your cut files

Project description

SnapMark

SnapMark is a Python library for applying intelligent, customizable text markings and engraving paths on DXF (AutoCAD) files. It is designed to generate laser-engraving traces (not cutting paths) that make each part identifiable through incised labels, codes, and metadata. Built on top of the excellent ezdxf, it provides a simple API for marking, alignment, hole analysis, and batch processing — tailored for manufacturing, CNC workflows, and automated drawing preparation.

PyPI version Python 3.8+ License: MIT


⚠️ Unit & Scale Notice

SnapMark is designed for sheet-metal parts measured in millimeters.

Since DXF files may contain arbitrary units (meters, inches, kilometers, or undefined scale), loading a drawing in a different unit system may produce text markings that appear extremely large, extremely small, or misplaced.

If your DXF is not in millimeters, you must rescale it before processing, or the resulting engraving paths may not match the actual geometry.

A scale-validation step will be added in a future release to automatically warn users when a drawing appears to be out of the expected millimeter range.

Installation

pip install snapmark

Quick Start

import snapmark as sm

# Mark all DXF files with their filename
sm.mark_by_name("path/to/drawings")

# Custom sequence: filename + folder name
seq = (sm.SequenceBuilder()
       .file_name()
       .folder(num_chars=2)   # firts 2 chars of folder name
       .build())

sm.mark_with_sequence("path/to/drawings", seq, scale_factor=100)

Features

  • Simple API - Mark files in a single function call
  • Custom sequences - Combine filename parts, folder names, literals, and custom logic
  • Automatic Alignment - Normalize orientation before marking
  • Batch Processing - Process folders and subfolders with IterationManager
  • Backup System - Automatic .bak creation and restoration
  • Hole Utilities - Fast hole detection and counting for quality checks
  • Extensible Architecture - Add your own operations and processing steps

Use Cases

  • Manufacturing: Add part numbers and quantities to production drawings
  • CAM workflows: Automatically mark drawings before CNC processing
  • Quality control: Count holes and verify drawing specifications
  • Batch processing: Apply consistent markings across large drawing sets

API Overview (Essentials)

Shortcuts (Simple Usage)

  • mark_by_name(folder) - Mark with filename
  • mark_by_splitted_text(folder, separator, part_index) - Mark with filename part
  • mark_with_sequence(folder, sequence) - Mark with custom sequence
  • quick_count_holes(folder, min_diam, max_diam) - Count holes
  • restore_backup(folder) - Restore from backups
  • process_single_file(file, *operations) - Pipeline on single file

SequenceBuilder (core)

seq = (sm.SequenceBuilder()
       .file_name()
       .file_part(separator="_", index=0)
       .folder(num_chars=2)
       .literal("TEXT")
       .custom(lambda folder, file: "X")
       .set_separator("-")
       .build())

Operations (Advanced)

  • AddMark(sequence) - Add text marking
  • Aligner() - Aligns the drawing along its longest side in the X direction.
  • CountHoles(find_func) - Count circles
  • AddX(find_func, x_size) - Add X marks
  • RemoveCircle(find_func) - Remove circles
  • SubstituteCircle(find_func, new_radius) - Replace circles

📘 Documentation: (Documentation files will be available in the docs/ directory.)

Requirements

  • Python 3.8+
  • ezdxf >= 1.0.0

Documentation

For detailed documentation and more examples, visit the GitHub repository.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE file for details.

Author

Federico Sidraschi
LinkedIn | GitHub

Acknowledgments

Built with ezdxf - the excellent DXF library for Python.


Keywords: DXF, CAD, AutoCAD, marking, automation, batch processing, manufacturing, CNC, CAM

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snapmark-2.0.4.tar.gz (33.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

snapmark-2.0.4-py3-none-any.whl (36.7 kB view details)

Uploaded Python 3

File details

Details for the file snapmark-2.0.4.tar.gz.

File metadata

  • Download URL: snapmark-2.0.4.tar.gz
  • Upload date:
  • Size: 33.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for snapmark-2.0.4.tar.gz
Algorithm Hash digest
SHA256 4b97fe14bd73daa15882719309433aa720be5ead6c3889e8e67b4b6bba071511
MD5 2b5311218df3abcec35b17f2247bf065
BLAKE2b-256 ae96c5bbdf99df105bae178f9e7fc43fe62a45e81ee4100f2b464a08be8bac25

See more details on using hashes here.

File details

Details for the file snapmark-2.0.4-py3-none-any.whl.

File metadata

  • Download URL: snapmark-2.0.4-py3-none-any.whl
  • Upload date:
  • Size: 36.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for snapmark-2.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 cf2f7c777b7125b5f12e952347dfbd11b4b84cf0e5dadd39a55e1594f7ff0fef
MD5 4ff7f6a0616cb474906290a2061c48f8
BLAKE2b-256 5c3fad51fd9acb1005b7b7578f2da84ae7cb5fff237d05898d30e7d2e501e0d8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page