Skip to main content

A Python package for generating drilling patterns for tunnel excavation based on AutoCAD polylines

Project description

PyDWG - Drilling Pattern Generator

A Python package for generating drilling patterns for tunnel excavation based on AutoCAD polylines. This tool creates optimized drilling patterns for various tunnel shapes, supporting both circular and arbitrary polyline geometries.

Features

  • Multi-format Input: Supports AutoCAD Lines, Arcs, and Polylines
  • Flexible Geometry: Works with both circular and arbitrary tunnel shapes
  • Four-Section Cut Pattern: Implements industry-standard four-section parallel cut patterns
  • Automatic Pattern Generation:
    • Cut holes (central relief and cutting pattern)
    • Stoping holes (interior grid pattern)
    • Contour holes (perimeter smooth blasting)
  • High-Fidelity Processing: Handles complex geometries with arc tessellation
  • AutoCAD Integration: Direct drawing and layer management

Installation

pip install pydwg

Quick Start

Prerequisites

  1. AutoCAD: Must be running and accessible
  2. Python: 3.7 or higher
  3. Dependencies: pyautocad, numpy

Basic Usage

  1. Draw your tunnel outline in AutoCAD on a layer named 0_dbm_polyline
  2. Run the generator:
from pydwg import FourSectionCutGenerator
from myAutoCAD import myAutoCAD

# Initialize
acad = myAutoCAD()
generator = FourSectionCutGenerator(acad)

# Read tunnel outline
tunnel_outline = generator.read_tunnel_outline_from_layer("0_dbm_polyline")

# Generate pattern
center, radius = generator.calculate_tunnel_center_and_radius(tunnel_outline)
advance_length = 3.5  # meters
hole_diameter = 0.045  # meters (45mm)

# Calculate parameters
df, dl, sections = generator.calculate_four_section_parameters(hole_diameter, advance_length)

# Generate all hole patterns
cut_holes = generator.generate_four_section_cut_pattern(center, sections, hole_diameter, dl)
stoping_holes = generator.generate_stoping_pattern(tunnel_outline, cut_holes, center, hole_diameter)
contour_holes = generator.generate_contour_holes(tunnel_outline, hole_diameter)

# Draw the pattern
all_holes = cut_holes + stoping_holes + contour_holes
generator.draw_drilling_pattern(all_holes, tunnel_outline)

Command Line Interface

pydwg

This will prompt you for:

  • Advance length (default: 3.5m)
  • Hole diameter (default: 45mm)

Advanced Features

Custom Pattern Types

The package supports different drilling pattern types:

  • Four-Section Cut: Industry standard for tunnel excavation
  • General Polyline: Works with any closed polyline shape
  • Contour Holes: Smooth blasting along tunnel perimeter
  • Stoping Holes: Interior grid pattern for bulk excavation

Geometry Processing

  • Arc Tessellation: Converts AutoCAD arcs to high-fidelity vertex sequences
  • Segment Ordering: Automatically orders disconnected segments into continuous paths
  • Polygon Analysis: Calculates weighted centroids and areas
  • Offset Operations: Creates parallel paths for contour holes

AutoCAD Integration

  • Layer Management: Automatic layer creation and organization
  • Entity Drawing: Circles, lines, and text annotations
  • Color Coding: Different colors for different hole types
  • Zoom and Save: Automatic view management and file saving

API Reference

Main Classes

FourSectionCutGenerator

The main class for generating drilling patterns.

Methods:

  • read_tunnel_outline_from_layer(layer_name): Read geometry from AutoCAD layer
  • calculate_tunnel_center_and_radius(vertices): Calculate weighted centroid and radius
  • generate_four_section_cut_pattern(center, sections, hole_diameter, empty_hole_diameter): Generate cut pattern
  • generate_stoping_pattern(tunnel_outline, cut_holes, center, hole_diameter): Generate stoping holes
  • generate_contour_holes(tunnel_outline, hole_diameter): Generate contour holes
  • draw_drilling_pattern(holes, tunnel_outline): Draw pattern in AutoCAD

Configuration

The package uses several configurable parameters:

  • Contour offset: Distance from tunnel perimeter (default: 0.3m)
  • Stoping spacing: Grid spacing for interior holes (default: 0.8m)
  • Cut pattern: Four-section parameters based on advance length
  • Hole diameters: Different sizes for different hole types

Examples

Circular Tunnel

# For circular tunnels, the pattern automatically adapts
# to the calculated radius and center

Irregular Tunnel

# For irregular shapes, the pattern follows the actual geometry
# with proper contour and stoping hole placement

Custom Parameters

# Customize pattern parameters
advance_length = 4.0  # meters
hole_diameter = 0.051  # meters (51mm)
contour_spacing = 0.35  # meters
stoping_burden = 0.9  # meters

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

License

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

Citation

If you use this software in your research, please cite:

@software{pydwg,
  title={PyDWG - Drilling Pattern Generator},
  author={Your Name},
  year={2024},
  url={https://github.com/yourusername/pydwg}
}

Support

Changelog

Version 1.0.0

  • Initial release
  • Four-section cut pattern generation
  • AutoCAD integration
  • Support for arbitrary polyline geometries
  • Arc tessellation and segment ordering

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

pydwg-1.0.0.tar.gz (7.1 MB view details)

Uploaded Source

Built Distribution

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

pydwg-1.0.0-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file pydwg-1.0.0.tar.gz.

File metadata

  • Download URL: pydwg-1.0.0.tar.gz
  • Upload date:
  • Size: 7.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for pydwg-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6fa7c3767b784631beadcbe65f281d6b6d39e6128db11a0acc60f1d63f71272f
MD5 d4148d302a9684216c88a7f52713baba
BLAKE2b-256 75f38d498617dd335d70ac4a8537471dd0cdb057017a06279d6ff9ba586e4a37

See more details on using hashes here.

File details

Details for the file pydwg-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pydwg-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for pydwg-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9d6f3ff72cc0b0195bbc8fb4b7b7c6fa258108034bc099e95aaf3b3f4e0f58d9
MD5 be57137a0873d7d7ee0033d58a1cb4bd
BLAKE2b-256 3474ece5583da9f07e09e395ad5ca69d8506d00d1bbfa836151d3c8d381d7a9e

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