- P&ID 그래프 파이프라인 구현 (py) - pid_geometric_extractor.py: 기하학적 특징 추출 - pid_intelligent_mapper.py: 태그 매핑 - pid_topology_builder.py: 위상 구축 - test_pipeline_phase2.py, test_pipeline_phase3.py: 테스트 - MCP 서버 개선 - server.py: 멀티프로세싱 지원 - pipeline/: 분석, 추출, 매핑, 위상 모듈 추가 - C# P&ID 그래프 서비스 - PidGraphDtos.cs: DTO 정의 - PidGraphService.cs: 비즈니스 로직 - PidGraphController.cs: API 컨트롤러 - OPC UA 서비스 개선 - ExperionOpcServerService.cs - ExperionRealtimeService.cs - ExperionFastService.cs - MCP 클라이언트 및 호스팅 서비스 개선 - McpClient.cs - McpServerHostedService.cs - 웹 UI 개선 - pid_graph_view.html: P&ID 그래프 뷰어 - pid-viewer.js: 뷰어 로직 - app.js: 메인 앱 - pid_graph.css: 스타일 - 프로젝트 설정 업데이트 - ExperionCrawler.csproj - Program.cs
P&ID Extractor
DXF / PDF 형식의 P&ID 도면에서 장비 및 계기 정보를 AI로 자동 추출하여 CSV, Excel(AX 포맷), PostgreSQL DB로 저장하는 파이프라인입니다.
추출 항목
| 필드 | 설명 | 예시 |
|---|---|---|
| Tag No. | 태그번호 | FT-1001, PT-2003, E-101 |
| Equipment Name | 장비명 | Flow Transmitter, Heat Exchanger |
| Instrument Type | 계기타입 | FT, PT, LT, CV, E, V, P |
| Line Number | 라인번호 | 6"-P-1001-A1A |
| P&ID Drawing No. | 도면번호 | P&ID-100-001 |
설치
1. 시스템 패키지 (PDF 변환용 poppler)
# Ubuntu/Debian
sudo apt-get install poppler-utils
# macOS
brew install poppler
# Windows: https://github.com/oschwartz10612/poppler-windows
2. Python 패키지
pip install -r requirements.txt
3. API 키 설정
export ANTHROPIC_API_KEY="sk-ant-..."
사용법
기본 실행 (DXF 파일)
python pid_extractor.py input/drawing_001.dxf
PDF 파일
python pid_extractor.py input/pid_sheet1.pdf input/pid_sheet2.pdf
여러 파일 + PostgreSQL 저장
python pid_extractor.py input/*.dxf input/*.pdf \
--db-dsn "postgresql://user:password@localhost:5432/pid_db" \
--output-dir output/
DXF 이미지 모드 (정확도 향상, 느림)
python pid_extractor.py input/drawing.dxf --image-mode
출력 파일
output/
├── pid_extracted_20250426_120000.csv # 전체 추출 데이터
├── pid_AX_import_20250426_120000.xlsx # AX 가져오기용 Excel
└── *.png # 변환된 이미지 파일들
logs/
└── extractor.log # 실행 로그
Python API 사용
from pid_extractor import run_pipeline
result = run_pipeline(
input_files=["input/P-001.dxf", "input/P-002.pdf"],
output_dir="output",
db_dsn="postgresql://user:pass@localhost:5432/pid_db", # 선택사항
)
print(f"추출 건수: {result['total']}")
print(f"CSV 저장: {result['csv']}")
print(f"Excel 저장: {result['excel']}")
PostgreSQL 스키마
psql -U postgres -d pid_db -f schema.sql
주요 쿼리
-- 계기 타입별 현황
SELECT instrument_type, COUNT(*) FROM pid_equipment GROUP BY instrument_type;
-- 검토 필요 항목 (신뢰도 낮음)
SELECT * FROM pid_equipment WHERE confidence < 0.7;
-- AX 내보내기 뷰
SELECT * FROM ax_export;
-- AX CSV 추출
COPY (SELECT * FROM ax_export) TO '/tmp/ax_import.csv' CSV HEADER;
AX (Asset Excellence) 컬럼 매핑
| 추출 필드 | AX 필드명 |
|---|---|
| tag_no | Tag Number |
| equipment_name | Asset Description |
| instrument_type | Equipment Class |
| pid_drawing_no | P&ID Reference |
| line_number | Line Reference |
| service_description | Service |
신뢰도(Confidence) 기준
| 색상 | 범위 | 의미 |
|---|---|---|
| 🟢 녹색 | 0.8 ~ 1.0 | 명확하게 읽힘 |
| 🟡 노란색 | 0.5 ~ 0.8 | 부분적으로 읽힘, 검토 권장 |
| 🔴 빨간색 | 0.0 ~ 0.5 | 불명확, 반드시 수동 검토 필요 |
워크플로우
DXF / PDF
│
▼
이미지/텍스트 변환
│
▼
Claude Vision API 분석
│
▼
JSON 파싱 & 정제
│
├──▶ CSV 저장
├──▶ AX Excel 저장
└──▶ PostgreSQL 저장