Convert SVG and DXF files to Prusa Core One G-code for plastic welding
Project description
MicroWeldr
A Python package that converts SVG and DXF files to Prusa Core One G-code for continuous plastic line welding. The package processes vector graphics and generates G-code that creates waterproof welded lines by placing many precise weld "dots" in sequence along the paths, without extruding any plastic material.
Multi-Format Support - Processes both SVG and DXF files with automatic weld type detection based on colors, layers, or filenames.
Optimized for Prusa Core One: Includes chamber temperature control (M141/M191), proper bed dimensions (250ร220ร270mm), and CoreXY-specific settings for reliable plastic welding operations.
This enables rapid microfluidics prototyping with a 3D printer by creating sealed, waterproof channels and barriers. Each vector path becomes a continuous welded line through precisely controlled sequential dot placement.
Complete welding process showing both normal welds (blue) and frangible welds (red) with 1mm spacing and 2mm diameter dots representing actual welding spots
๐ Version 6.1.4
- Unified Configuration: Consistent 1mm dot spacing across SVG and DXF formats
- Professional Examples: Complete example collection with combined weld types
- Improved Animations: Uniform timing with 3-second pause for final result viewing
- Proper Weld Heights: 0.1mm normal welds, 0.6mm frangible welds for breakaway functionality
- Comprehensive Testing: Full test coverage including weld height validation
- Modern Dependencies: Updated to pytest 9.0.1, pre-commit 4.4.0, optimized package set
- CI/CD Ready: Complete GitHub Actions workflows with multi-platform testing
Project Structure
microweldr/
โโโ microweldr/ # Main package
โ โโโ core/ # Core functionality & configuration
โ โ โโโ config.py # Configuration management
โ โ โโโ unified_config.py # Unified configuration system
โ โ โโโ data_models.py # Structured data models
โ โ โโโ events.py # Event system for processing
โ โ โโโ constants.py # Application constants
โ โโโ parsers/ # File format parsers
โ โ โโโ dxf_reader.py # DXF file processing
โ โ โโโ svg_parser.py # SVG file processing
โ โ โโโ enhanced_svg_parser.py # Advanced SVG features
โ โโโ generators/ # Point and G-code generation
โ โ โโโ point_iterator_factory.py # Factory pattern for iterators
โ โ โโโ svg_point_iterator.py # SVG point generation
โ โ โโโ dxf_point_iterator.py # DXF point generation
โ โโโ outputs/ # Output generation
โ โ โโโ streaming_gcode_subscriber.py # G-code generation
โ โ โโโ gif_animation_subscriber.py # Animation generation
โ โโโ cli/ # Command line interface
โ โ โโโ simple_main.py # Main CLI entry point
โ โ โโโ enhanced_main.py # Advanced CLI features
โ โโโ prusalink/ # Printer integration
โโโ tests/ # Comprehensive test suite
โ โโโ unit/ # Unit tests (121 tests)
โ โโโ parsing/ # Parser tests
โ โโโ outputs/ # Output generation tests
โ โโโ test_linting.py # Code quality tests
โโโ examples/ # Professional example collection
โ โโโ flask_simple.svg # SVG example (628 points)
โ โโโ flask.dxf # DXF example (467 points)
โ โโโ combined_normal.dxf # Combined example (801 points)
โ โโโ combined_frangible.dxf # Frangible welds (5 points)
โ โโโ *.gif # Generated animations
โโโ pyproject.toml # Modern Poetry configuration (PEP 621)
Features
File Format Support
- SVG Files: Paths, lines, circles, rectangles, groups, and use elements
- DXF Files: Lines, arcs, circles, polylines, and LWPOLYLINES
- Multi-File Processing: Mix SVG and DXF files in single command
- Unit Validation: DXF files must use millimeters (throws exception otherwise)
- Construction Filtering: Automatically ignores construction layers in DXF
Weld Type Detection
Multiple methods for determining weld types:
1. Color-Based (SVG)
- Black elements โ Normal welds
- Blue elements โ Frangible welds (breakaway seals)
- Red elements โ Stop points (pause for user intervention)
- Magenta elements โ Pipette points (filling operations)
2. Layer-Based (DXF)
- Normal layers: Any layer name
- Frangible layers: Containing
frangible,light,break,seal,weak - Construction layers: Containing
construction,const,guide,reference,ref(ignored)
3. Filename-Based (Fallback)
When colors/layers don't specify weld type, filenames are checked:
- Normal welds:
main_welds.dxf,structure.svg - Frangible welds:
frangible_seals.dxf,light_welds.svg,break_points.dxf
Advanced Features
- Configurable Parameters: TOML-based configuration for temperatures, heights, and timing
- Multi-Pass Welding: Configurable initial and final dot spacing
- Optimized Z Movement: Separate weld move height for faster intra-path welding
- Chamber Temperature Control: Prusa Core One chamber heating
- Animation Output: Generates animated SVG showing the welding sequence
- Proper G-code Structure: Includes heating, cooling, and safety procedures
- Error Handling: Comprehensive error reporting and recovery
- Statistics Collection: Processing metrics and validation results
Installation
From PyPI
pip install microweldr
With DXF Support
pip install microweldr[dxf] # Includes ezdxf for DXF processing
From Source
git clone https://github.com/retospect/microweldr.git
cd microweldr
poetry install --with dev
Quick Start
Basic Usage
# Convert single SVG file
microweldr -weld design.svg -g_out output.gcode
# Convert DXF file with unit validation
microweldr -weld drawing.dxf -g_out output.gcode
# Process combined normal and frangible welds
microweldr -weld main_welds.dxf -frange frangible_seals.dxf -g_out combined.gcode
# Generate animation along with G-code
microweldr -weld design.svg -g_out output.gcode -animation output_animation.gif
Fusion 360 Workflow
Perfect for CAD-based microfluidics design:
- Design in Fusion 360: Create your microfluidic channels and seals
- Export two DXF files:
main_welds.dxf- Primary structural weldsfrangible_seals.dxf- Breakaway seals for filling ports
- Process both files:
microweldr -weld main_welds.dxf -frange frangible_seals.dxf -g_out device.gcode - Print: Load G-code on Prusa Core One
Configuration
Create microweldr_config.toml for custom settings:
[printer]
bed_x = 250
bed_y = 220
bed_z = 270
chamber_temperature = 45
[movement]
move_height = 5.0 # mm - height for safe movement between paths
weld_height = 0.02 # mm - height for actual welding (touching plastic)
weld_move_height = 2.0 # mm - height for moving between weld points (faster than safe height)
frame_height = 10.0 # mm - height for frame drawing (clearance check)
travel_speed = 3000 # mm/min - travel speed for movements
z_speed = 600 # mm/min - optimized Z speed (near maximum safe limit for Core One)
[normal_welds]
weld_height = 0.1 # mm - structural weld depth
weld_temperature = 160 # ยฐC - nozzle temperature
weld_time = 0.1 # seconds - dwell time
dot_spacing = 0.5 # mm - unified spacing
[frangible_welds]
weld_height = 0.6 # mm - deeper for breakaway functionality
weld_temperature = 160 # ยฐC - same temperature
weld_time = 0.3 # seconds - longer for controlled weakness
dot_spacing = 0.5 # mm - unified spacing
[output]
gcode_extension = ".gcode"
animation_extension = "_animation.svg"
Command Reference
Main Command
microweldr [OPTIONS]
Options:
-weld PATH Normal weld file (SVG or DXF)
-frange PATH Frangible weld file (SVG or DXF)
-g_out PATH Output G-code file
-animation PATH Output animation GIF file
-quiet Suppress verbose output
--help Show help message
Examples
# Single file processing
microweldr -weld design.svg -g_out output.gcode
# Combined weld types
microweldr -weld structural.dxf -frange seals.dxf -g_out device.gcode
# With animation
microweldr -weld design.svg -animation preview.gif -g_out output.gcode
File Format Details
SVG Support
- Elements:
<path>,<line>,<circle>,<rect>,<g>,<use> - Attributes:
stroke,class,idfor weld type detection - Namespaces: Handles standard SVG namespaces
- Definitions: Processes
<defs>and referenced elements
DXF Support
- Entities: LINE, ARC, CIRCLE, POLYLINE, LWPOLYLINE
- Units: Must be millimeters (validated automatically)
- Layers: Used for weld type and construction detection
- Coordinate System: Preserves original coordinates
Weld Type Examples
Filename-Based Detection
# These filenames automatically detect frangible welds:
microweldr convert frangible_seals.dxf # โ Frangible
microweldr convert light_connections.svg # โ Frangible
microweldr convert break_points.dxf # โ Frangible
microweldr convert seal_layer.svg # โ Frangible
# These default to normal welds:
microweldr convert main_structure.dxf # โ Normal
microweldr convert primary_welds.svg # โ Normal
Layer-Based Detection (DXF)
Layer "main_welds" โ Normal welds
Layer "frangible_seals" โ Frangible welds
Layer "construction" โ Ignored
Layer "break_points" โ Frangible welds
Development
Running Tests
poetry run pytest # All tests
poetry run pytest tests/unit/ # Unit tests only
poetry run pytest -v # Verbose output
Code Quality
poetry run black . # Format code
poetry run bandit -r microweldr/ # Security check
poetry run pre-commit run --all-files # All checks
Building
poetry build # Build wheel and source
poetry install dist/*.whl # Install local build
Examples
Professional Examples
# See examples/ directory for complete example collection:
# - flask_simple.svg (628 points, Bรฉzier curves)
# - flask.dxf (467 points, line interpolation)
# - combined_normal.dxf + combined_frangible.dxf (806 total points)
# Process the combined example
microweldr -weld examples/combined_normal.dxf \
-frange examples/combined_frangible.dxf \
-g_out examples/combined_animation.gif \
-animation examples/combined_animation.gif
Production Workflow
# 1. Design in CAD software (Fusion 360, etc.)
# 2. Export separate files for different weld types
# 3. Process with MicroWeldr
microweldr -weld structural_welds.dxf -frange breakaway_seals.dxf -g_out device.gcode
# 4. Load G-code on Prusa Core One and print
Troubleshooting
DXF Issues
- Unit Error: Ensure DXF uses millimeters in drawing units
- No Entities: Check that layers contain supported entities (lines, arcs, circles)
- Construction Layers: Rename layers to avoid construction keywords
SVG Issues
- No Paths: Ensure elements have
strokeattribute (not justfill) - Complex Paths: Curves are approximated with line segments
- Nested Groups: Deep nesting may affect processing
Weld Type Detection
- Wrong Type: Check filename, layer names, or SVG colors
- All Normal: Add frangible keywords to filenames or layers
- All Frangible: Remove frangible keywords from filenames
Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make changes with tests:
poetry run pytest - Format code:
poetry run black . - Submit pull request
License
MIT License - see LICENSE file for details.
Changelog
Version 5.3.0 (Latest)
- NEW: Full DXF file support with ezdxf integration
- NEW: Multi-file processing (mix SVG and DXF)
- NEW: Filename-based weld type detection as fallback
- BREAKING: Renamed "light_welds" to "frangible_welds" in all configs
- IMPROVED: Modular CLI architecture with better error handling
- IMPROVED: Publisher-subscriber file processing framework
- IMPROVED: Comprehensive test coverage (33 tests)
- IMPROVED: Structured data models with validation
Version 5.2.x
- Enhanced SVG processing
- Animation improvements
- Configuration validation
Version 5.1.x
- Initial public release
- Basic SVG to G-code conversion
- Prusa Core One optimization
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file microweldr-6.1.4.tar.gz.
File metadata
- Download URL: microweldr-6.1.4.tar.gz
- Upload date:
- Size: 152.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2eb7fff47b72b89f97293195d05e8088d6905afc6f0c6fd363afc8efa63afc93
|
|
| MD5 |
898d5c17d930c845ca2feacaa056c2f5
|
|
| BLAKE2b-256 |
82ab9a6075629dd898e5a66de051c5ecd2cbe1ed2c48b5b22cc05d5662c9bea1
|
Provenance
The following attestation bundles were made for microweldr-6.1.4.tar.gz:
Publisher:
pypi_publish.yml on retospect/microweldr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
microweldr-6.1.4.tar.gz -
Subject digest:
2eb7fff47b72b89f97293195d05e8088d6905afc6f0c6fd363afc8efa63afc93 - Sigstore transparency entry: 707903194
- Sigstore integration time:
-
Permalink:
retospect/microweldr@0f42f17ca5c7a7e56674342151c11a4a5e501112 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/retospect
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi_publish.yml@0f42f17ca5c7a7e56674342151c11a4a5e501112 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file microweldr-6.1.4-py3-none-any.whl.
File metadata
- Download URL: microweldr-6.1.4-py3-none-any.whl
- Upload date:
- Size: 186.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17a9d97529d64e14620b3bac83c895d0bcf360bd9bf60d71a03ea9a1594af627
|
|
| MD5 |
97b118e0cbb09417c86ce4d93214eeae
|
|
| BLAKE2b-256 |
57895d32fa60114a8c990df9c829542d33071e7a03a070cc8097eaa59a632a4d
|
Provenance
The following attestation bundles were made for microweldr-6.1.4-py3-none-any.whl:
Publisher:
pypi_publish.yml on retospect/microweldr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
microweldr-6.1.4-py3-none-any.whl -
Subject digest:
17a9d97529d64e14620b3bac83c895d0bcf360bd9bf60d71a03ea9a1594af627 - Sigstore transparency entry: 707903197
- Sigstore integration time:
-
Permalink:
retospect/microweldr@0f42f17ca5c7a7e56674342151c11a4a5e501112 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/retospect
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi_publish.yml@0f42f17ca5c7a7e56674342151c11a4a5e501112 -
Trigger Event:
workflow_dispatch
-
Statement type: