This skill should be used when the user wants to read, analyze, or work with CAD DWG/DXF drawing files. Trigger phrases include: DWG, DXF, CAD drawing, drawi...
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install cad-viewer或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install cad-viewer⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/cad-viewer/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: cad-viewer description: "This skill should be used when the user wants to read, analyze, or work with CAD DWG/DXF drawing files. Trigger phrases include: DWG, DXF, CAD drawing, drawing analysis, layer, block, entity, screenshot, distance calculation, drawing audit, electrical diagram, distribution box, single-line diagram, or any mention of .dwg/.dxf files. This skill provides comprehensive CAD drawing analysis capabilities including reading file metadata, listing layers and entities, analyzing block definitions, calculating distances between entities, capturing screenshots of specific regions or entities, and auditing drawing compliance." ---
Provide professional-grade DWG/DXF drawing file reading and analysis capabilities. This skill enables structured data extraction from CAD drawings, spatial analysis between entities, visual capture of drawing regions, and standards compliance auditing.
Before using this skill, please review the following:
This skill does NOT automatically install any packages or run any setup scripts. If dependencies are missing, it will output a clear error message with manual installation instructions. To set up the environment, the user must explicitly run the setup command:
# Assisted setup (requires explicit --confirm flag)
python3 {SKILL_DIR}/scripts/cad_tools.py setup --confirm
The full setup process (when explicitly confirmed) will:
ezdxf, matplotlib)xvfb, libGL) via sudoopendesign.comqcad.orgAll downloads are from official sources, but the skill requires network access and elevated permissions.
ezdxf and matplotlib must be installed before useInstall dependencies yourself before using the skill:
# 1. Install Python packages
pip3 install ezdxf matplotlib
# 2. Install system packages (Ubuntu/Debian)
sudo apt-get install xvfb libgl1-mesa-glx libglu1-mesa
# 3. Download and install ODA File Converter manually from:
# https://www.opendesign.com/guestfiles/oda_file_converter
# 4. Download and extract QCAD dwg2bmp manually from:
# https://qcad.org/en/download
# Then set: export QCAD_DWG2BMP_PATH=/path/to/qcad/dwg2bmp
Run the setup script with explicit confirmation:
# Run setup with interactive confirmation
python3 {SKILL_DIR}/scripts/cad_tools.py setup --confirm
# Or manually specify packages you have already downloaded
python3 {SKILL_DIR}/scripts/cad_tools.py setup --oda-rpm /path/to/ODAFileConverter_xxx.rpm --qcad-tar /path/to/qcad-xxx-trial-linux-x86_64.tar.gz
What setup does (with your confirmation):
ezdxf, matplotlib) - requiredxvfb virtual display - optional but recommendedopendesign.com - required for DWG supportqcad.org - optional, for high-quality screenshotsODA Download: https://www.opendesign.com/guestfiles/oda_file_converter (free registration required) QCAD Download: https://qcad.org/en/download (Professional Trial)
python3 {SKILL_DIR}/scripts/cad_tools.py check-env
Outputs JSON-formatted dependency status, including whether each component is installed, its path, and repair commands if missing.
When to use: Run check-env to diagnose issues when any command fails.
All operations use a single CLI tool located at:
scripts/cad_tools.py
Usage pattern:
python3 {SKILL_DIR}/scripts/cad_tools.py COMMAND DWG_FILE [OPTIONS]
All commands output structured JSON to stdout, making the results directly parseable.
info — Get Drawing Basic InformationRead file version, units, entity count summary, and metadata.
python3 {SKILL_DIR}/scripts/cad_tools.py info /path/to/drawing.dwg
Output includes: DXF version, drawing units, layer count, block count, entity type breakdown.
When to use: As the first step when analyzing any new DWG file. Always start with info to understand the drawing's scope.
layers — List All LayersList all layer definitions with color, linetype, and state (on/off/locked/frozen).
python3 {SKILL_DIR}/scripts/cad_tools.py layers /path/to/drawing.dwg --count-entities --sort-by name
Options:
--count-entities: Count entities on each layer (slower but informative)--sort-by name|color: Sort layers by name or colorWhen to use: To understand the drawing's organizational structure and identify which layers contain relevant content.
entities — List Model Space EntitiesList entities with optional type and layer filtering.
python3 {SKILL_DIR}/scripts/cad_tools.py entities /path/to/drawing.dwg --type INSERT --layer "EC.SingleLine" --limit 20
Options:
--type: Filter by entity type (INSERT, LINE, CIRCLE, TEXT, MTEXT, LWPOLYLINE, ARC, etc.)--layer: Filter by layer name (exact match)--limit: Maximum number of resultsWhen to use: To inspect specific types of entities or explore a particular layer's contents.
blocks — List Block DefinitionsList all block definitions (templates) with their internal entity composition.
python3 {SKILL_DIR}/scripts/cad_tools.py blocks /path/to/drawing.dwg --name-filter "breaker"
Options:
--name-filter: Filter blocks by name (case-insensitive substring match)When to use: To catalog available equipment types and standard components in the drawing.
inserts — List Block Reference InstancesList block reference instances (placed equipment/components) in model space.
python3 {SKILL_DIR}/scripts/cad_tools.py inserts /path/to/drawing.dwg --name-filter "10KV" --analyze-layers --limit 50
Options:
--name-filter: Filter by block name--analyze-layers: Show internal layer distribution of each block--limit: Maximum resultsWhen to use: To find specific equipment instances, their positions, and verify their layer assignments.
texts — Extract Text ContentExtract all text content (TEXT, MTEXT, and block attributes).
python3 {SKILL_DIR}/scripts/cad_tools.py texts /path/to/drawing.dwg --keyword "distribution" --limit 30
Options:
--keyword: Filter by keyword (case-insensitive)--limit: Maximum resultsWhen to use: To find labels, annotations, equipment names, or any textual information in the drawing.
layer-content — Extract Layer Entity DetailsGet all entities on a specific layer with full details.
python3 {SKILL_DIR}/scripts/cad_tools.py layer-content /path/to/drawing.dwg "EC.SingleLine" --limit 20
When to use: To deeply inspect the contents of a particular professional layer.
spaces — View Space Layout SystemList all spaces (model space, paper space, block definitions).
python3 {SKILL_DIR}/scripts/cad_tools.py spaces /path/to/drawing.dwg --detail
Options:
--detail: Include viewport information for paper spacesWhen to use: To understand the drawing's overall structure and printing layout.
distance — Calculate Distance Between Points/EntitiesCalculate 2D and 3D distances between two entities or coordinates.
# By block names
python3 {SKILL_DIR}/scripts/cad_tools.py distance /path/to/drawing.dwg --entity1 "10KV.GenSet.01IncomingHV" --entity2 "10KV.RouteA-01Incoming.BreakerHV"
# By coordinates
python3 {SKILL_DIR}/scripts/cad_tools.py distance /path/to/drawing.dwg --coord1 "100,200" --coord2 "500,600"
# Mixed: entity + coordinate
python3 {SKILL_DIR}/scripts/cad_tools.py distance /path/to/drawing.dwg --entity1 "10KV.GenSet.01IncomingHV" --coord2 "500,600"
Output includes: 2D distance, 3D distance, delta X/Y/Z, and unit.
When to use: To verify clearance requirements, check equipment spacing, or measure distances between specific points.
screenshot — Entity/Region ScreenshotCapture a visual image of a specific entity, layer, or region.
# Screenshot centered on a specific block
python3 {SKILL_DIR}/scripts/cad_tools.py screenshot /path/to/drawing.dwg --block-name "10KV.GenSet.01IncomingHV" --radius 5000 -o /path/to/output.png
# Screenshot of an entire layer's bounding box
python3 {SKILL_DIR}/scripts/cad_tools.py screenshot /path/to/drawing.dwg --layer-name "EC.SingleLine" -o /path/to/layer_view.png
# Screenshot of a custom region (x, y, width, height)
python3 {SKILL_DIR}/scripts/cad_tools.py screenshot /path/to/drawing.dwg --region "-2580000,1020000,60000,40000" -o /path/to/region.png
# Full drawing screenshot
python3 {SKILL_DIR}/scripts/cad_tools.py screenshot /path/to/drawing.dwg -o /path/to/full.png
Options:
--block-name: Center on a named block instance--handle: Center on entity by handle--layer-name: Capture the bounding box of all entities on a layer--region "x,y,w,h": Specify exact capture region--radius: Expansion radius around entity center (default: 5000)--output / -o: Output file path (supports .png, .pdf, .svg)--pixel-size: Image resolution (default: 3000)--background: Background color (default: black)--qcad-path: Path to QCAD dwg2bmp toolWhen to use: To visually inspect equipment, verify spatial arrangements, or generate images for reports and multimodal AI analysis.
audit — Drawing Compliance AuditRun automated compliance checks on the drawing.
python3 {SKILL_DIR}/scripts/cad_tools.py audit /path/to/drawing.dwg
Checks performed:
Output: Issue list with severity (error/warning/info), rule name, and details.
When to use: Before submitting drawings for review, or when auditing received drawings for compliance.
search — Search Entities by KeywordSearch entities by keyword across block names, text content, and layer names.
python3 {SKILL_DIR}/scripts/cad_tools.py search /path/to/drawing.dwg "transformer" --limit 20
When to use: To quickly locate specific equipment, annotations, or components by name.
export-pdf — Export to PDFConvert the drawing to a vector PDF file.
python3 {SKILL_DIR}/scripts/cad_tools.py export-pdf /path/to/drawing.dwg -o /path/to/output.pdf --background "#FFFFFF"
When to use: To generate a portable visual representation of the drawing.
When analyzing a new DWG file, follow this order:
.learning/ for relevant experience (see Self-Learning Mechanism)info → Understand file basics (version, units, entity count)layers → See the organizational structureinserts or entities → Find specific equipment/componentstexts → Extract textual annotationsdistance → Measure spatial relationshipsscreenshot → Capture visuals for detailed inspectionaudit → Check complianceFor detailed understanding of DWG file structure, entity types, layer conventions, and CAD coordinate systems, refer to:
references/cad_knowledge.md
This reference covers: DWG file hierarchy, entity type catalog, unit systems, layer naming conventions for data center drawings, and common audit rules.
All commands produce JSON output to stdout. Error messages go to stderr. Exit code 0 indicates success, non-zero indicates failure.
Example output structure (for info command):
{
"file": "/absolute/path/to/drawing.dwg",
"dxf_version": "AC1032",
"unit": "Millimeters",
"unit_code": 4,
"total_layers": 45,
"total_blocks": 120,
"modelspace_entity_count": 343,
"entity_type_summary": {
"INSERT": 36,
"LINE": 58,
"LWPOLYLINE": 6,
"TEXT": 15,
"MTEXT": 228
}
}
{SKILL_DIR} placeholder refers to the directory containing this SKILL.md fileassets/.setup_done to skip future setupassets/.setup_done and run any commandThis skill supports a self-learning mechanism that records user preferences, error resolutions, and best practices discovered during usage. These records are stored in a .learning/ directory within the user's project and are automatically referenced in subsequent sessions to provide more accurate and personalized assistance.
Unless the user explicitly requests to skip past experience (e.g., "don't refer to previous learnings", "start fresh"), the agent MUST review .learning/ files at the beginning of every task and apply relevant knowledge throughout the session.
To prevent records from growing indefinitely and losing their effectiveness, strict limits are enforced:
| File | Max Entries | Eviction Trigger | |------|-------------|------------------| | LEARNINGS.md | 50 | When adding a new entry would exceed 50 | | ERRORS.md | 30 | When adding a new entry would exceed 30 |
Counting method: Count the number of ## [ heading lines in the file to determine the current entry count.
Eviction strategy — when the limit is reached, before adding a new entry, remove the lowest-value entry using this priority order:
resolved entries are evicted first (already addressed, least future value)wont_fix entries are evicted nextLogged datelow < medium < high < critical)Important rules:
pending and in_progress entries are never evicted automatically — if all entries are pending/in_progress and the limit is reached, the agent should ask the user which entry to remove or resolve## [ to the next ---)user_preference category) have eviction protection — they are only evicted when no other candidates remain, because preferences are persistently valuableQuick count check (the agent should do this before adding a new entry):
grep -c "^## \[" .learning/LEARNINGS.md
grep -c "^## \[" .learning/ERRORS.md
Before logging anything, ensure the .learning/ directory and files exist in the user's project root (NOT in the skill directory). If any are missing, create them:
mkdir -p .learning
[ -f .learning/LEARNINGS.md ] || cp {SKILL_DIR}/assets/LEARNINGS.md .learning/LEARNINGS.md
[ -f .learning/ERRORS.md ] || cp {SKILL_DIR}/assets/ERRORS.md .learning/ERRORS.md
Never overwrite existing files. This is a no-op if .learning/ is already initialized.
At the start of every CAD analysis task, before executing any commands:
.learning/ directory exists in the project root.learning/LEARNINGS.md and .learning/ERRORS.md- If a user preference for screenshot background color was recorded, use it automatically - If a known error with certain DWG versions was logged, warn the user or apply the fix preemptively - If a best practice for specific layer analysis was discovered, follow it
| Situation | Action | |-----------|--------| | Command fails or produces unexpected output | Log to .learning/ERRORS.md | | User corrects the agent's approach | Log to .learning/LEARNINGS.md with category correction | | User specifies a preference (e.g., output format, default options) | Log to .learning/LEARNINGS.md with category user_preference | | A non-obvious solution is discovered | Log to .learning/LEARNINGS.md with category insight | | Agent's knowledge about CAD was incorrect or outdated | Log to .learning/LEARNINGS.md with category knowledge_gap | | A better workflow or approach is found | Log to .learning/LEARNINGS.md with category best_practice |
Append to .learning/LEARNINGS.md:
## [LRN-YYYYMMDD-XXX] category
**Logged**: ISO-8601 timestamp
**Priority**: low | medium | high | critical
**Status**: pending
### Summary
One-line description of what was learned
### Details
Full context: what happened, what was wrong, what's correct
### Suggested Action
Specific fix or improvement to apply in future sessions
### Metadata
- Source: conversation | error | user_feedback
- Related Files: path/to/file.dwg
- Tags: tag1, tag2
- See Also: LRN-YYYYMMDD-XXX (if related to existing entry)
---
Append to .learning/ERRORS.md:
## [ERR-YYYYMMDD-XXX] command_name
**Logged**: ISO-8601 timestamp
**Priority**: high
**Status**: pending
### Summary
Brief description of what failed
### Error
Actual error message or output
### Context
- Command/operation attempted
- Input file and parameters used
- Environment details if relevant
### Resolution
How the error was resolved (fill in once fixed)
### Metadata
- Reproducible: yes | no | unknown
- Related Files: path/to/file.dwg
- See Also: ERR-YYYYMMDD-XXX (if recurring)
---
Format: TYPE-YYYYMMDD-XXX
LRN (learning), ERR (error)001, 002)Examples: LRN-20260408-001, ERR-20260408-001
When an issue is fixed or a learning is confirmed, update the entry:
Status: pending → Status: resolved### Resolution section.learning/ directory is local to the project and is NOT committed to version control by defaultAdd to the project's .gitignore:
.learning/
┌──────────────────────────────────────────────────────────┐
│ Agent Task Start │
│ │
│ 1. Does .learning/ exist? │
│ ├─ YES → Read LEARNINGS.md & ERRORS.md │
│ │ Apply relevant past experience │
│ └─ NO → Initialize .learning/ directory │
│ │
│ 2. Execute the user's CAD analysis task │
│ └─ Apply past learnings throughout │
│ │
│ 3. During execution, did any of these occur? │
│ ├─ Error encountered → Log to ERRORS.md │
│ ├─ User correction → Log to LEARNINGS.md │
│ ├─ User preference → Log to LEARNINGS.md │
│ ├─ New insight → Log to LEARNINGS.md │
│ └─ Nothing notable → No logging needed │
│ │
│ 4. Before writing a new entry: │
│ ├─ Count existing entries (grep -c "^## \[" file) │
│ ├─ At limit? → Evict lowest-value entry first │
│ │ (resolved > wont_fix > oldest > lowest priority) │
│ └─ Under limit? → Append directly │
│ │
│ 5. Task complete │
└──────────────────────────────────────────────────────────┘安装 CAD Viewer 后,可以对 AI 说这些话来触发它
Help me get started with CAD Viewer
Explains what CAD Viewer does, walks through the setup, and runs a quick demo based on your current project
Use CAD Viewer to this skill should be used when the user wants to read, analyze, or ...
Invokes CAD Viewer with the right parameters and returns the result directly in the conversation
What can I do with CAD Viewer in my marketing & growth workflow?
Lists the top use cases for CAD Viewer, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/cad-viewer/ 目录(个人级,所有项目可用),或 .claude/skills/cad-viewer/(项目级)。重启 AI 客户端后,用 /cad-viewer 主动调用,或让 AI 根据上下文自动发现并使用。
CAD Viewer 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
CAD Viewer 可免费安装使用。请查阅仓库了解许可证信息。
This skill should be used when the user wants to read, analyze, or work with CAD DWG/DXF drawing files. Trigger phrases include: DWG, DXF, CAD drawing, drawi...
CAD Viewer 属于「Marketing & Growth」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my marketing & growth tasks using CAD Viewer
Identifies repetitive steps in your workflow and sets up CAD Viewer to handle them automatically