pydwg


Namepydwg JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/SanjeevBashyal/UTHP
SummaryA Python package for generating drilling patterns for tunnel excavation based on AutoCAD polylines
upload_time2025-08-04 12:49:45
maintainerNone
docs_urlNone
authorSanjeev Bashyal
requires_python>=3.7
licenseMIT
keywords drilling pattern tunnel excavation autocad civil engineering mining
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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

```bash
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**:

```python
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

```bash
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

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

### Irregular Tunnel

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

### Custom Parameters

```python
# 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](LICENSE) file for details.

## Citation

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

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

## Support

- **Issues**: [GitHub Issues](https://github.com/yourusername/pydwg/issues)
- **Documentation**: [GitHub Wiki](https://github.com/yourusername/pydwg/wiki)
- **Email**: your.email@example.com

## Changelog

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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/SanjeevBashyal/UTHP",
    "name": "pydwg",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "Sanjeev Bashyal <sanjeev.bashyal01@gmail.com>",
    "keywords": "drilling, pattern, tunnel, excavation, autocad, civil engineering, mining",
    "author": "Sanjeev Bashyal",
    "author_email": "Sanjeev Bashyal <sanjeev.bashyal01@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/75/f3/8d498617dd335d70ac4a8537471dd0cdb057017a06279d6ff9ba586e4a37/pydwg-1.0.0.tar.gz",
    "platform": null,
    "description": "# PyDWG - Drilling Pattern Generator\r\n\r\nA 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.\r\n\r\n## Features\r\n\r\n- **Multi-format Input**: Supports AutoCAD Lines, Arcs, and Polylines\r\n- **Flexible Geometry**: Works with both circular and arbitrary tunnel shapes\r\n- **Four-Section Cut Pattern**: Implements industry-standard four-section parallel cut patterns\r\n- **Automatic Pattern Generation**: \r\n  - Cut holes (central relief and cutting pattern)\r\n  - Stoping holes (interior grid pattern)\r\n  - Contour holes (perimeter smooth blasting)\r\n- **High-Fidelity Processing**: Handles complex geometries with arc tessellation\r\n- **AutoCAD Integration**: Direct drawing and layer management\r\n\r\n## Installation\r\n\r\n```bash\r\npip install pydwg\r\n```\r\n\r\n## Quick Start\r\n\r\n### Prerequisites\r\n\r\n1. **AutoCAD**: Must be running and accessible\r\n2. **Python**: 3.7 or higher\r\n3. **Dependencies**: pyautocad, numpy\r\n\r\n### Basic Usage\r\n\r\n1. **Draw your tunnel outline** in AutoCAD on a layer named `0_dbm_polyline`\r\n2. **Run the generator**:\r\n\r\n```python\r\nfrom pydwg import FourSectionCutGenerator\r\nfrom myAutoCAD import myAutoCAD\r\n\r\n# Initialize\r\nacad = myAutoCAD()\r\ngenerator = FourSectionCutGenerator(acad)\r\n\r\n# Read tunnel outline\r\ntunnel_outline = generator.read_tunnel_outline_from_layer(\"0_dbm_polyline\")\r\n\r\n# Generate pattern\r\ncenter, radius = generator.calculate_tunnel_center_and_radius(tunnel_outline)\r\nadvance_length = 3.5  # meters\r\nhole_diameter = 0.045  # meters (45mm)\r\n\r\n# Calculate parameters\r\ndf, dl, sections = generator.calculate_four_section_parameters(hole_diameter, advance_length)\r\n\r\n# Generate all hole patterns\r\ncut_holes = generator.generate_four_section_cut_pattern(center, sections, hole_diameter, dl)\r\nstoping_holes = generator.generate_stoping_pattern(tunnel_outline, cut_holes, center, hole_diameter)\r\ncontour_holes = generator.generate_contour_holes(tunnel_outline, hole_diameter)\r\n\r\n# Draw the pattern\r\nall_holes = cut_holes + stoping_holes + contour_holes\r\ngenerator.draw_drilling_pattern(all_holes, tunnel_outline)\r\n```\r\n\r\n### Command Line Interface\r\n\r\n```bash\r\npydwg\r\n```\r\n\r\nThis will prompt you for:\r\n- Advance length (default: 3.5m)\r\n- Hole diameter (default: 45mm)\r\n\r\n## Advanced Features\r\n\r\n### Custom Pattern Types\r\n\r\nThe package supports different drilling pattern types:\r\n\r\n- **Four-Section Cut**: Industry standard for tunnel excavation\r\n- **General Polyline**: Works with any closed polyline shape\r\n- **Contour Holes**: Smooth blasting along tunnel perimeter\r\n- **Stoping Holes**: Interior grid pattern for bulk excavation\r\n\r\n### Geometry Processing\r\n\r\n- **Arc Tessellation**: Converts AutoCAD arcs to high-fidelity vertex sequences\r\n- **Segment Ordering**: Automatically orders disconnected segments into continuous paths\r\n- **Polygon Analysis**: Calculates weighted centroids and areas\r\n- **Offset Operations**: Creates parallel paths for contour holes\r\n\r\n### AutoCAD Integration\r\n\r\n- **Layer Management**: Automatic layer creation and organization\r\n- **Entity Drawing**: Circles, lines, and text annotations\r\n- **Color Coding**: Different colors for different hole types\r\n- **Zoom and Save**: Automatic view management and file saving\r\n\r\n## API Reference\r\n\r\n### Main Classes\r\n\r\n#### `FourSectionCutGenerator`\r\n\r\nThe main class for generating drilling patterns.\r\n\r\n**Methods:**\r\n- `read_tunnel_outline_from_layer(layer_name)`: Read geometry from AutoCAD layer\r\n- `calculate_tunnel_center_and_radius(vertices)`: Calculate weighted centroid and radius\r\n- `generate_four_section_cut_pattern(center, sections, hole_diameter, empty_hole_diameter)`: Generate cut pattern\r\n- `generate_stoping_pattern(tunnel_outline, cut_holes, center, hole_diameter)`: Generate stoping holes\r\n- `generate_contour_holes(tunnel_outline, hole_diameter)`: Generate contour holes\r\n- `draw_drilling_pattern(holes, tunnel_outline)`: Draw pattern in AutoCAD\r\n\r\n### Configuration\r\n\r\nThe package uses several configurable parameters:\r\n\r\n- **Contour offset**: Distance from tunnel perimeter (default: 0.3m)\r\n- **Stoping spacing**: Grid spacing for interior holes (default: 0.8m)\r\n- **Cut pattern**: Four-section parameters based on advance length\r\n- **Hole diameters**: Different sizes for different hole types\r\n\r\n## Examples\r\n\r\n### Circular Tunnel\r\n\r\n```python\r\n# For circular tunnels, the pattern automatically adapts\r\n# to the calculated radius and center\r\n```\r\n\r\n### Irregular Tunnel\r\n\r\n```python\r\n# For irregular shapes, the pattern follows the actual geometry\r\n# with proper contour and stoping hole placement\r\n```\r\n\r\n### Custom Parameters\r\n\r\n```python\r\n# Customize pattern parameters\r\nadvance_length = 4.0  # meters\r\nhole_diameter = 0.051  # meters (51mm)\r\ncontour_spacing = 0.35  # meters\r\nstoping_burden = 0.9  # meters\r\n```\r\n\r\n## Contributing\r\n\r\n1. Fork the repository\r\n2. Create a feature branch\r\n3. Make your changes\r\n4. Add tests\r\n5. Submit a pull request\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\r\n\r\n## Citation\r\n\r\nIf you use this software in your research, please cite:\r\n\r\n```bibtex\r\n@software{pydwg,\r\n  title={PyDWG - Drilling Pattern Generator},\r\n  author={Your Name},\r\n  year={2024},\r\n  url={https://github.com/yourusername/pydwg}\r\n}\r\n```\r\n\r\n## Support\r\n\r\n- **Issues**: [GitHub Issues](https://github.com/yourusername/pydwg/issues)\r\n- **Documentation**: [GitHub Wiki](https://github.com/yourusername/pydwg/wiki)\r\n- **Email**: your.email@example.com\r\n\r\n## Changelog\r\n\r\n### Version 1.0.0\r\n- Initial release\r\n- Four-section cut pattern generation\r\n- AutoCAD integration\r\n- Support for arbitrary polyline geometries\r\n- Arc tessellation and segment ordering \r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python package for generating drilling patterns for tunnel excavation based on AutoCAD polylines",
    "version": "1.0.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/SanjeevBashyal/UTHP/issues",
        "Documentation": "https://github.com/SanjeevBashyal/UTHP",
        "Homepage": "https://github.com/SanjeevBashyal/UTHP",
        "Repository": "https://github.com/SanjeevBashyal/UTHP"
    },
    "split_keywords": [
        "drilling",
        " pattern",
        " tunnel",
        " excavation",
        " autocad",
        " civil engineering",
        " mining"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "3474ece5583da9f07e09e395ad5ca69d8506d00d1bbfa836151d3c8d381d7a9e",
                "md5": "be57137a0873d7d7ee0033d58a1cb4bd",
                "sha256": "9d6f3ff72cc0b0195bbc8fb4b7b7c6fa258108034bc099e95aaf3b3f4e0f58d9"
            },
            "downloads": -1,
            "filename": "pydwg-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "be57137a0873d7d7ee0033d58a1cb4bd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 16677,
            "upload_time": "2025-08-04T12:49:39",
            "upload_time_iso_8601": "2025-08-04T12:49:39.931694Z",
            "url": "https://files.pythonhosted.org/packages/34/74/ece5583da9f07e09e395ad5ca69d8506d00d1bbfa836151d3c8d381d7a9e/pydwg-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "75f38d498617dd335d70ac4a8537471dd0cdb057017a06279d6ff9ba586e4a37",
                "md5": "d4148d302a9684216c88a7f52713baba",
                "sha256": "6fa7c3767b784631beadcbe65f281d6b6d39e6128db11a0acc60f1d63f71272f"
            },
            "downloads": -1,
            "filename": "pydwg-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "d4148d302a9684216c88a7f52713baba",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 7070875,
            "upload_time": "2025-08-04T12:49:45",
            "upload_time_iso_8601": "2025-08-04T12:49:45.956572Z",
            "url": "https://files.pythonhosted.org/packages/75/f3/8d498617dd335d70ac4a8537471dd0cdb057017a06279d6ff9ba586e4a37/pydwg-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-04 12:49:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "SanjeevBashyal",
    "github_project": "UTHP",
    "github_not_found": true,
    "lcname": "pydwg"
}
        
Elapsed time: 1.39349s