A powerful command-line tool with a Terminal User Interface (TUI) for extracting data from DWG files. Convert DWG files to DXF format and interactively explore layers, blocks, text, and other CAD entities with advanced filtering, selection, and clipboard integration.
- Description
- Features
- Prerequisites
- Installation
- Usage
- Configuration
- Build from Source
- Examples
- Troubleshooting
- Contributing
- License
Go DWG Extractor is a cross-platform application that provides both command-line and Terminal User Interface modes for working with DWG files. It leverages the ODA File Converter to convert DWG files to DXF format, then provides powerful tools for exploring and extracting data from the converted files.
The application features a modern TUI with keyboard shortcuts, layer filtering, entity selection, and clipboard integration, making it easy to work with CAD data in terminal environments.
- Cross-platform support - Works on Windows, Linux, and macOS
- Terminal User Interface - Modern, responsive TUI with keyboard navigation
- DWG to DXF conversion - Automatic conversion using ODA File Converter
- Layer filtering - Advanced search and filter capabilities for layers
- Entity exploration - Browse lines, circles, text, blocks, and polylines
- Clipboard integration - Copy selected data in multiple formats (text, CSV, JSON)
- Keyboard shortcuts - Efficient navigation with Ctrl+C, F1, Tab, and more
- Multiple output formats - Export data as text, CSV, or JSON
- Error handling - Comprehensive error reporting with recovery suggestions
- Version information - Built-in version tracking and build metadata
Before installing Go DWG Extractor, ensure you have the following:
- Go 1.18+ - For building from source
- ODA File Converter - For DWG to DXF conversion
- Download from: https://www.opendesign.com/guestfiles/oda_file_converter
- Install to default location or set
ODA_CONVERTER_PATHenvironment variable
- Windows - Windows 10/11 (amd64)
- Linux - Ubuntu 18.04+ or equivalent (amd64)
- macOS - macOS 10.15+ (amd64, arm64)
- Download the latest release for your platform from the Releases page
- Extract the archive to your desired location
- Add the executable to your PATH (optional)
# Clone the repository
git clone https://github.com/remym/go-dwg-extractor.git
cd go-dwg-extractor
# Build and install
make installGo DWG Extractor provides two main modes of operation:
Extract data from DWG files and output to console:
# Extract data from a DWG file
./go-dwg-extractor extract -file sample.dwg
# Extract with custom output directory
./go-dwg-extractor extract -file sample.dwg -output ./outputLaunch the interactive TUI for exploring DWG data:
# Launch TUI with a specific DWG file
./go-dwg-extractor tui -file sample.dwg
# Launch TUI with sample data (for testing)
./go-dwg-extractor tui# Show version information
./go-dwg-extractor version# Show help information
./go-dwg-extractor helpThe application can be configured using environment variables:
ODA_CONVERTER_PATH- Path to ODA File Converter executable- Default:
C:\Program Files\ODA\ODAFileConverter 26.4.0\ODAFileConverter.exe(Windows) - Example:
export ODA_CONVERTER_PATH="/usr/local/bin/ODAFileConverter"
- Default:
The application automatically detects and validates the ODA File Converter installation. If the converter is not found in the default location, set the ODA_CONVERTER_PATH environment variable.
# Build for current platform
make build
# Build for all platforms
make build-all
# Create distribution packages
make package
# Complete build pipeline
make allYou can also use the Makefile directly for various build tasks:
# Available Makefile targets
build: # Build for current platform
build-all: # Build for all platforms
test: # Run all tests
test-coverage: # Run tests with coverage
package: # Create distribution packages
clean: # Clean build artifacts
help: # Show available targets# Run complete build pipeline
./scripts/build.sh all
# Build only
./scripts/build.sh build
# Clean previous builds
./scripts/build.sh clean# Run complete build pipeline
.\scripts\build.ps1 all
# Build with specific version
.\scripts\build.ps1 all -Version "v1.0.0"
# Build only
.\scripts\build.ps1 build# Build with version information
go build -ldflags "-X main.version=v1.0.0 -X main.gitCommit=$(git rev-parse --short HEAD) -X main.buildTime=$(date -u '+%Y-%m-%dT%H:%M:%SZ')" -o go-dwg-extractor .# Extract layer information from a DWG file
./go-dwg-extractor extract -file architectural-plan.dwg
# Launch TUI to explore the file interactively
./go-dwg-extractor tui -file architectural-plan.dwgOnce in the TUI mode, use these keyboard shortcuts:
- Tab - Switch between panes (search, layers, entities, details)
- ↑/↓ - Navigate within lists
- Enter - Select item or layer
- Space - Toggle layer visibility
- Ctrl+C - Copy selected items to clipboard
- Ctrl+F - Focus search input
- F1 - Toggle help view
- Escape - Clear selection or go back
- Ctrl+Q - Quit application
- Navigate to a layer or entity in the TUI
- Press Ctrl+C to copy to clipboard
- Data is copied in multiple formats (text, CSV, JSON)
- Paste into your preferred text editor or spreadsheet
In the TUI search box, you can use:
- Text search: Type layer name to filter
- Status filter:
on:trueoron:falseto filter by visibility - Frozen filter:
frozen:trueorfrozen:falseto filter by frozen status
Error: ODA File Converter not found at default path
Solution:
- Download and install ODA File Converter from the official website
- Set the
ODA_CONVERTER_PATHenvironment variable:export ODA_CONVERTER_PATH="/path/to/ODAFileConverter"
Error: Permission denied when accessing DWG file
Solution:
- Check file permissions:
chmod 644 your-file.dwg - Ensure you have read access to the file
- Run with appropriate user permissions
Error: DWG file format not supported
Solution:
- Verify the file is a valid DWG file
- Check if the DWG version is supported by ODA File Converter
- Try converting the file to a newer DWG format using AutoCAD
Error: Failed to convert DWG to DXF
Solution:
- Check if the DWG file is corrupted
- Verify ODA File Converter is properly installed
- Ensure sufficient disk space for conversion
- Check the application logs for detailed error information
For detailed debugging information, you can:
- Check the application logs
- Run with verbose output (if available)
- Verify the ODA File Converter works independently
If you encounter issues not covered here:
- Check the Issues page
- Create a new issue with:
- Your operating system and version
- Go DWG Extractor version (
./go-dwg-extractor version) - Steps to reproduce the problem
- Error messages or logs
We welcome contributions to Go DWG Extractor! Here's how you can help:
- Fork the repository
- Clone your fork:
git clone https://github.com/yourusername/go-dwg-extractor.git - Create a feature branch:
git checkout -b feature/your-feature-name - Make your changes following the coding standards
- Run tests:
make test - Submit a pull request
- Follow Go best practices and conventions
- Write tests for new functionality (TDD approach)
- Maintain test coverage above 80%
- Use meaningful commit messages
- Update documentation as needed
# Run all tests
make test
# Run tests with coverage
make test-coverage
# Run specific package tests
go test ./pkg/tui/ -vThis project is licensed under the MIT License - see the LICENSE file for details.
Go DWG Extractor - Making CAD data accessible in terminal environments.
For more information, visit the project repository.