Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cadlens

PyPI version

Official Python SDK for Cadlens — the CAD file preview API that converts DWG, DXF, and DWF files into preview images, structured JSON, layer metadata, and vector entities.


Install

pip install cadlens

Requires Python 3.8+ and httpx.


Quick Start

from cadlens import CadlensClient

client = CadlensClient(api_key="cadl_your_key_here")

# One-shot: upload + poll + return result
result = client.parse_and_wait("drawing.dwg")

print("Layers:  ", len(result.layers_json))
print("Entities:", len(result.vector_json))
print("Metadata:", result.metadata)
print("Preview: ", result.image_url)

Step-by-step Usage

import time
from cadlens import CadlensClient

client = CadlensClient(api_key="cadl_your_key_here")

# 1. Upload
upload = client.parse("drawing.dwg")
job_id = upload["job_id"]
print("Job ID:", job_id)

# 2. Poll
while True:
    job = client.get_job(job_id)
    print("Status:", job.status)
    if job.status == "COMPLETED":
        break
    if job.status == "FAILED":
        raise RuntimeError("Job failed")
    time.sleep(3)

# 3. Result
result = client.get_result(job_id)
print(result.metadata)
print(result.vector_json[:5])

Context Manager

with CadlensClient(api_key="cadl_your_key_here") as client:
    result = client.parse_and_wait("drawing.dwg")

API Reference

CadlensClient(api_key, base_url?)

Argument Type Description
api_key str Your cadl_xxx API key (required)
base_url str Override API base URL (default: https://api.cadlens.co)

Methods

Method Returns Description
parse(file, file_name?, webhook_url?, mode?) dict Upload a CAD file; get a job_id
parse_and_wait(file, ...) JobResult Upload, poll, and return result
get_job(job_id) Job Get job status and metadata
list_jobs() list[Job] List recent jobs (up to 100)
get_result(job_id) JobResult Get file, summary, sheets[] (entities + layers per sheet)
get_image(job_id) str Get presigned PNG preview URL (1h TTL)
delete_job(job_id) None Delete job and S3 artifacts

Supported Formats

DWG · DXF · DWF · DWFx · DGN · PDF


Get an API Key

Sign up at cadlens.co, go to the dashboard, and create an API key. Keys start with cadl_.


Links


GitHub Topics

Add these topics to this repo for discovery: cad dwg dxf python sdk pip cad-api engineering-api automation aec


License

MIT

About

Official Python SDK for the Cadlens CAD parsing API — DWG, DXF, DWF to JSON and PNG previews

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages