GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - cadlens-co/cadlens-api-examples: Code examples for the Cadlens CAD parsing API — DWG, DXF, DWF to JSON and PNG previews

BranchesTags
Open more actions menu

Latest commit

 

History

13 Commits
13 Commits

Folders and files

NameName
Last commit message
Last commit date
examples
examples
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

Cadlens API Examples

Cadlens is a developer API for parsing CAD files such as DWG, DXF, and DWF into preview images, structured JSON, layer metadata, and vector entities — without installing AutoCAD or any desktop software.

  • Website: cadlens.co
  • API Docs: cadlens.co/docs
  • Pricing: cadlens.co/pricing
  • Dashboard: cadlens.co/dashboard

What you can build with Cadlens

  • CAD file preview inside your web app — CAD file preview API
  • DWG/DXF to structured JSON extraction — DWG to JSON API
  • Layer and entity inspection for automation workflows
  • AI-assisted CAD interpretation with LLMs
  • Webhook-based async CAD processing pipelines

Prerequisites

  1. Sign up at cadlens.co and create an account
  2. Go to the dashboard and generate an API key (starts with cadl_)
  3. Export your key: export CADLENS_API_KEY=cadl_your_key_here

Examples

File Description
examples/upload.sh Upload a CAD file, poll for completion, retrieve result
examples/webhook.sh Upload with a webhook URL and example webhook payload
examples/node.js Node.js upload using native fetch
examples/python.py Python upload using requests

Basic Flow

  1. Upload — POST a CAD file to /v1/parse; receive a job_id
  2. Poll — GET /v1/jobs/:job_id until status is COMPLETED or FAILED
  3. Retrieve — GET /v1/jobs/:job_id/result for vector JSON, layers, and metadata
  4. Preview — GET /v1/jobs/:job_id/image for a presigned PNG preview URL

Supported File Formats

DWG · DXF · DWF · DWFx · DGN · PDF


Quick Response Preview

Job status response (GET /v1/jobs/:job_id):

{
  "id": "job_lH9k2c",
  "status": "COMPLETED",
  "fileName": "drawing.dwg",
  "fileSize": 2048576,
  "createdAt": "2026-05-15T12:00:00.000Z",
  "completedAt": "2026-05-15T12:01:30.000Z",
  "imageUrl": "https://s3.amazonaws.com/..."
}

Result response (GET /v1/jobs/:job_id/result):

{
  "schemaVersion": "2.0.0",
  "parserVersion": "2.0.0",
  "jobId": "job_lH9k2c",
  "status": "COMPLETED",
  "file": { "name": "drawing.dwg", "format": "DWG", "version": "AC1021", "units": "mm" },
  "summary": {
    "totalSheets": 1, "totalEntities": 142, "totalLayers": 8,
    "statistics": {
      "byType": { "LINE": 98, "TEXT": 30, "INSERT": 14 },
      "byCategory": { "Geometry": 98, "Annotation": 30, "BlockReference": 14 }
    },
    "truncated": false
  },
  "sheets": [
    {
      "name": "Model", "key": "model", "index": 0,
      "imageUrl": "https://s3.amazonaws.com/.../preview-0.png?...",
      "entityCount": 142, "layerCount": 8,
      "layers": [{ "name": "0", "color": 7, "colorHex": "#FFFFFF", "isVisible": true, "entityCount": 20 }],
      "entities": [
        {
          "id": "1A4", "handle": "1A4", "type": "LINE", "category": "Geometry",
          "layer": "0", "layout": "Model",
          "geometry": { "start": { "x": 0, "y": 0 }, "end": { "x": 100, "y": 100 } },
          "text": null, "reference": null,
          "properties": { "colorIndex": 7, "lineType": null, "lineweight": null, "visible": true, "solid": null, "patternName": null, "patternAngle": null, "patternScale": null },
          "bbox": { "minX": 0, "minY": 0, "maxX": 100, "maxY": 100 },
          "metrics": { "length": 141.421356, "area": null, "perimeter": null, "vertexCount": 2 }
        }
      ]
    }
  ],
  "parseInfo": { "durationMs": 812, "warnings": [], "errors": [] },
  "imageUrl": "https://s3.amazonaws.com/.../preview-0.png?...",
  "imageUrls": ["https://s3.amazonaws.com/.../preview-0.png?..."]
}

Entities use the Schema v2 envelope: spatial coordinates live under entity.geometry (per-type fields, original precision), with sibling text (TEXT/MTEXT), reference (INSERT block name), properties, and always-present computed bbox and metrics (null values where not applicable).


Webhook Payload

When you supply a webhookUrl on upload, Cadlens POSTs this to your endpoint on completion:

{
  "eventId": "550e8400-e29b-41d4-a716-446655440000",
  "sequence": 1,
  "event": "job.completed",
  "jobId": "job_lH9k2c",
  "status": "COMPLETED",
  "timestamp": "2026-05-15T12:01:30.000Z",
  "result": {
    "schemaVersion": "2.0.0",
    "imageUrl": "https://s3.amazonaws.com/...",
    "imageUrls": ["https://s3.amazonaws.com/..."],
    "file": { "name": "drawing.dwg", "format": "DWG", "version": "AC1021", "units": "mm" },
    "summary": { "totalSheets": 1, "totalEntities": 142, "totalLayers": 8, "truncated": false },
    "sheets": [ /* same structure as GET /result */ ]
  }
}

Webhook events: job.processing · job.completed · job.failed


Links

  • Cadlens official website
  • Cadlens API documentation
  • Cadlens pricing
  • Contact Cadlens

GitHub Topics

Add these topics to this repo for discovery: cad dwg dxf cad-parser dwg-parser cad-api engineering-api aec developer-tools construction-tech

About

Code examples for the Cadlens CAD parsing API — DWG, DXF, DWF to JSON and PNG previews

cadlens.co/docs

Topics

aeccadcad-apicad-parserconstruction-techdeveloper-toolsdwgdwg-parserdxfengineering-api

Resources

Readme
MIT license
Activity
Custom properties

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.