πŸ—οΈ DXFConvertor: AI-Powered Architectural Drawing to DXF Converter

Inspiration

Architects and engineers frequently receive floor plans as scanned images or PDF documents instead of editable CAD files. Converting these documents into DXF format is traditionally a manual process that involves tracing walls, doors, windows, annotations, and furniture inside CAD softwareβ€”a workflow that is both time-consuming and error-prone.

Our goal was to build an intelligent system capable of understanding architectural drawings and automatically generating professional DXF files while preserving structural information, room annotations, and architectural entities.


What it Does

DXFConvertor is an AI-powered CAD processing toolkit that converts architectural images and PDFs into editable DXF files.

The system automatically detects:

  • 🧱 Walls
  • πŸšͺ Doors
  • πŸͺŸ Windows
  • πŸ›οΈ Columns
  • πŸͺœ Stairs
  • πŸ›‹οΈ Furniture & Fixtures
  • πŸ“ Room Names using OCR
  • 🏒 Multiple Floors from PDF documents

Besides generating AutoCAD-compatible DXF files, the application also produces structured JSON metadata containing every detected architectural component.


How We Built It

The project combines Computer Vision, OCR, Geometry Analysis, and CAD generation into a single processing pipeline.

Image Processing

We preprocess architectural drawings using:

  • OpenCV
  • Adaptive Thresholding
  • Morphological Operations
  • Edge Detection
  • Hough Line Transform
  • Contour Detection

This helps remove noise while preserving important structural details.

Entity Detection

After preprocessing, the system identifies architectural components based on:

  • Line orientation
  • Shape analysis
  • Contour geometry
  • Connected components
  • Spatial relationships

Different algorithms classify walls, doors, windows, columns, stairs, furniture, and fixtures.

OCR

Room labels, dimensions, and textual annotations are extracted using OCR after deskewing and image enhancement.

DXF Generation

Detected entities are converted into AutoCAD-standard DXF objects using:

  • Standard Layers
  • Colors
  • Line Types
  • Line Weights
  • Coordinate Mapping

The resulting DXF files can be opened directly in AutoCAD, LibreCAD, or DraftSight.

Multi-Floor Processing

For PDF floor plans, every page is treated as an individual floor.

The application automatically:

  1. Extracts each page
  2. Detects architectural entities
  3. Generates individual DXF files
  4. Produces JSON metadata
  5. Creates an overall building summary

System Workflow

Input Image / PDF
        β”‚
        β–Ό
 Image Preprocessing
        β”‚
        β–Ό
 Edge & Line Detection
        β”‚
        β–Ό
 Architectural Entity Detection
        β”‚
        β–Ό
 Furniture Detection
        β”‚
        β–Ό
 OCR Annotation Extraction
        β”‚
        β–Ό
 AutoCAD DXF Generation
        β”‚
        β–Ό
 DXF + JSON Metadata

What We Learned

This project taught us that architectural drawings are significantly more complex than conventional computer vision datasets.

Some major learnings include:

  • Image preprocessing greatly influences OCR accuracy.
  • Computer vision alone is insufficient without architectural heuristics.
  • Proper layer organization is essential for CAD interoperability.
  • Modular software architecture makes large computer vision systems easier to maintain and extend.
  • Small improvements in preprocessing can significantly improve downstream detection accuracy.

We also gained valuable experience integrating multiple technologies into a single production-ready workflow.


Challenges We Faced

Handling Different Drawing Standards

Floor plans vary widely in quality, scale, symbols, and drawing conventions.

We designed configurable preprocessing pipelines that adapt to different blueprint styles.


Distinguishing Similar Objects

Furniture often resembles walls or structural elements.

We combined:

  • Shape descriptors
  • Aspect ratios
  • Area thresholds
  • Spatial heuristics

to improve classification accuracy.


OCR Reliability

Scanned floor plans often contain:

  • Noise
  • Rotated text
  • Low resolution
  • Broken characters

To improve OCR performance, we implemented:

  • Adaptive thresholding
  • Deskewing
  • Noise removal
  • Morphological enhancement

CAD Compatibility

Producing DXF files compatible with professional CAD software required careful implementation of:

  • AutoCAD layers
  • Entity ordering
  • Coordinate transformations
  • Line styles
  • Standard CAD conventions

Performance Optimization

Large buildings contain thousands of architectural entities.

We optimized our processing pipeline to reduce execution time while maintaining high detection quality.


Accomplishments We're Proud Of

  • βœ… Automated Image/PDF β†’ DXF conversion
  • βœ… Multi-floor building processing
  • βœ… AI-assisted architectural entity detection
  • βœ… OCR-based room annotation extraction
  • βœ… Professional AutoCAD-standard DXF generation
  • βœ… Structured JSON metadata for downstream analysis
  • βœ… Modular, scalable architecture

Mathematical Perspective

One of our optimization goals was minimizing detection error.

The objective can be represented as

$$ E = \sum_{i=1}^{n} \left| P_i - G_i \right| $$

where:

  • $P_i$ represents the predicted architectural entity
  • $G_i$ represents the corresponding ground-truth entity

Our processing pipeline aims to minimize the total detection error:

$$ \min E $$

while maximizing structural consistency across the generated DXF.


What's Next

We plan to extend DXFConvertor with:

  • πŸ€– Deep Learning-based object detection
  • 🏒 BIM (Building Information Modeling) integration
  • πŸ“ Automatic area and dimension estimation
  • πŸ› οΈ Interactive web-based CAD editing
  • ☁️ Cloud deployment for large-scale processing
  • πŸ“Š AI-assisted building analytics
  • 🧩 3D floor plan reconstruction

Conclusion

DXFConvertor demonstrates how Computer Vision, OCR, and CAD automation can transform static architectural drawings into structured, editable CAD files. By automating a traditionally manual workflow, the project helps architects, engineers, and construction professionals reduce processing time, improve accuracy, and accelerate design workflows.

Built With

  • pdf2image-ocr:-pytesseract-cad/dxf-handling:-ezdxf-data/geometry-support:-shapely
  • pillow
  • pytest
  • scikit-image
  • scikit-learn
  • testing:
  • the-stack-used-for-this-project-is:-language:-python-web-framework:-flask-image/pdf-processing:-opencv
Share this project:

Updates