도면에서 표 추출
This commit is contained in:
@@ -17,7 +17,7 @@ namespace DwgExtractorManual.Models
|
||||
{
|
||||
// 컴포넌트들
|
||||
private readonly ExcelManager excelManager;
|
||||
private readonly DwgDataExtractor dwgExtractor;
|
||||
public readonly DwgDataExtractor DwgExtractor;
|
||||
private readonly JsonDataProcessor jsonProcessor;
|
||||
private readonly ExcelDataWriter excelWriter;
|
||||
private readonly FieldMapper fieldMapper;
|
||||
@@ -29,7 +29,7 @@ namespace DwgExtractorManual.Models
|
||||
private Dictionary<string, Dictionary<string, (string, string, string, string)>> FileToMapkeyToLabelTagValuePdf
|
||||
= new Dictionary<string, Dictionary<string, (string, string, string, string)>>();
|
||||
|
||||
readonly List<string> MapKeys;
|
||||
readonly List<string>? MapKeys;
|
||||
|
||||
/// <summary>
|
||||
/// 생성자: 모든 컴포넌트 초기화
|
||||
@@ -41,7 +41,7 @@ namespace DwgExtractorManual.Models
|
||||
Debug.WriteLine("🔄 FieldMapper 로딩 중: mapping_table_json.json...");
|
||||
fieldMapper = FieldMapper.LoadFromFile("fletimageanalysis/mapping_table_json.json");
|
||||
Debug.WriteLine("✅ FieldMapper 로딩 성공");
|
||||
MapKeys = fieldMapper.GetAllDocAiKeys();
|
||||
MapKeys = fieldMapper.GetAllDocAiKeys() ?? new List<string>();
|
||||
Debug.WriteLine($"📊 총 DocAI 키 개수: {MapKeys?.Count ?? 0}");
|
||||
|
||||
// 매핑 테스트 (디버깅용)
|
||||
@@ -52,7 +52,7 @@ namespace DwgExtractorManual.Models
|
||||
|
||||
// 컴포넌트들 초기화
|
||||
excelManager = new ExcelManager();
|
||||
dwgExtractor = new DwgDataExtractor(fieldMapper);
|
||||
DwgExtractor = new DwgDataExtractor(fieldMapper);
|
||||
jsonProcessor = new JsonDataProcessor();
|
||||
excelWriter = new ExcelDataWriter(excelManager);
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace DwgExtractorManual.Models
|
||||
try
|
||||
{
|
||||
// DWG 데이터 추출
|
||||
var extractionResult = dwgExtractor.ExtractFromDwgFile(filePath, progress, cancellationToken);
|
||||
var extractionResult = DwgExtractor.ExtractFromDwgFile(filePath, progress, cancellationToken);
|
||||
|
||||
if (extractionResult == null)
|
||||
{
|
||||
@@ -191,14 +191,14 @@ namespace DwgExtractorManual.Models
|
||||
|
||||
try
|
||||
{
|
||||
var worksheet = firstSheetProcessed ?
|
||||
heightSortedWorkbook.Worksheets.Add() :
|
||||
Microsoft.Office.Interop.Excel.Worksheet worksheet = firstSheetProcessed ?
|
||||
(Microsoft.Office.Interop.Excel.Worksheet)heightSortedWorkbook.Worksheets.Add() :
|
||||
(Microsoft.Office.Interop.Excel.Worksheet)heightSortedWorkbook.Worksheets[1];
|
||||
|
||||
worksheet.Name = excelManager.GetValidSheetName(fileName);
|
||||
firstSheetProcessed = true;
|
||||
|
||||
var textEntities = dwgExtractor.ExtractTextEntitiesWithHeight(dwgFile);
|
||||
var textEntities = DwgExtractor.ExtractTextEntitiesWithHeight(dwgFile);
|
||||
excelWriter.WriteHeightSortedData(textEntities, worksheet, fileName);
|
||||
|
||||
Debug.WriteLine($"[DEBUG] {fileName} 시트 완료: {textEntities.Count}개 엔티티");
|
||||
@@ -212,7 +212,7 @@ namespace DwgExtractorManual.Models
|
||||
|
||||
if (!firstSheetProcessed)
|
||||
{
|
||||
var defaultSheet = (Microsoft.Office.Interop.Excel.Worksheet)heightSortedWorkbook.Worksheets[1];
|
||||
Microsoft.Office.Interop.Excel.Worksheet defaultSheet = (Microsoft.Office.Interop.Excel.Worksheet)heightSortedWorkbook.Worksheets[1];
|
||||
defaultSheet.Name = "No_DWG_Files";
|
||||
defaultSheet.Cells[1, 1] = "No DWG files found in this folder";
|
||||
}
|
||||
@@ -238,6 +238,10 @@ namespace DwgExtractorManual.Models
|
||||
{
|
||||
Debug.WriteLine($"[DEBUG] 단일 Excel 파일로 Height 정렬 생성 시작: {allDwgFiles.Count}개 파일");
|
||||
|
||||
// 시각화 데이터 초기화
|
||||
MainWindow.ClearVisualizationData();
|
||||
Debug.WriteLine("[VISUALIZATION] 시각화 데이터 초기화 완료");
|
||||
|
||||
var heightSortedWorkbook = excelManager.CreateNewWorkbook();
|
||||
bool firstSheetProcessed = false;
|
||||
|
||||
@@ -252,22 +256,22 @@ namespace DwgExtractorManual.Models
|
||||
|
||||
try
|
||||
{
|
||||
var worksheet = firstSheetProcessed ?
|
||||
heightSortedWorkbook.Worksheets.Add() :
|
||||
Microsoft.Office.Interop.Excel.Worksheet worksheet = firstSheetProcessed ?
|
||||
(Microsoft.Office.Interop.Excel.Worksheet)heightSortedWorkbook.Worksheets.Add() :
|
||||
(Microsoft.Office.Interop.Excel.Worksheet)heightSortedWorkbook.Worksheets[1];
|
||||
|
||||
worksheet.Name = excelManager.GetValidSheetName(fileName);
|
||||
firstSheetProcessed = true;
|
||||
|
||||
var textEntities = dwgExtractor.ExtractTextEntitiesWithHeight(filePath);
|
||||
var textEntities = DwgExtractor.ExtractTextEntitiesWithHeight(filePath);
|
||||
excelWriter.WriteHeightSortedData(textEntities, worksheet, fileName);
|
||||
|
||||
// Note 엔티티 추출 및 기록
|
||||
var noteEntities = dwgExtractor.ExtractNotesFromDrawing(filePath);
|
||||
if (noteEntities.Count > 0)
|
||||
var noteEntities = DwgExtractor.ExtractNotesFromDrawing(filePath);
|
||||
if (noteEntities.NoteEntities.Count > 0)
|
||||
{
|
||||
excelWriter.WriteNoteEntities(noteEntities, worksheet, fileName);
|
||||
Debug.WriteLine($"[DEBUG] {fileName}: {noteEntities.Count}개 Note 엔티티 추가됨");
|
||||
excelWriter.WriteNoteEntities(noteEntities.NoteEntities, worksheet, fileName);
|
||||
Debug.WriteLine($"[DEBUG] {fileName}: {noteEntities.NoteEntities.Count}개 Note 엔티티 추가됨");
|
||||
}
|
||||
|
||||
Debug.WriteLine($"[DEBUG] {fileName} 시트 완료: {textEntities.Count}개 엔티티");
|
||||
@@ -281,7 +285,7 @@ namespace DwgExtractorManual.Models
|
||||
|
||||
if (!firstSheetProcessed)
|
||||
{
|
||||
var defaultSheet = (Microsoft.Office.Interop.Excel.Worksheet)heightSortedWorkbook.Worksheets[1];
|
||||
Microsoft.Office.Interop.Excel.Worksheet defaultSheet = (Microsoft.Office.Interop.Excel.Worksheet)heightSortedWorkbook.Worksheets[1];
|
||||
defaultSheet.Name = "No_DWG_Files";
|
||||
defaultSheet.Cells[1, 1] = "No DWG files found in any folder";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user