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.
- Website: cadlens.co
- API Docs: cadlens.co/docs
- Dashboard: cadlens.co/dashboard
pip install cadlensRequires Python 3.8+ and httpx.
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)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])with CadlensClient(api_key="cadl_your_key_here") as client:
result = client.parse_and_wait("drawing.dwg")| Argument | Type | Description |
|---|---|---|
api_key |
str |
Your cadl_xxx API key (required) |
base_url |
str |
Override API base URL (default: https://api.cadlens.co) |
| 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 |
DWG · DXF · DWF · DWFx · DGN · PDF
Sign up at cadlens.co, go to the dashboard, and create an API key. Keys start with cadl_.
Add these topics to this repo for discovery:
cad dwg dxf python sdk pip cad-api engineering-api automation aec
MIT