Import: DXF, add dedicated import dialog

This commit is contained in:
Furgo
2025-06-29 08:53:38 +02:00
parent c238be2857
commit 293ebf801c
8 changed files with 462 additions and 76 deletions

View File

@@ -53,6 +53,7 @@
#include <gp_Vec.hxx>
#endif
#include <fstream>
#include <App/Annotation.h>
#include <App/Application.h>
#include <App/Document.h>
@@ -80,6 +81,35 @@ using namespace Import;
using BRepAdaptor_HCurve = BRepAdaptor_Curve;
#endif
std::map<std::string, int> ImpExpDxfRead::PreScan(const std::string& filepath)
{
std::map<std::string, int> counts;
std::ifstream ifs(filepath);
if (!ifs) {
// Could throw an exception or log an error
return counts;
}
std::string line;
bool next_is_entity_name = false;
while (std::getline(ifs, line)) {
// Simple trim for Windows-style carriage returns
if (!line.empty() && line.back() == '\r') {
line.pop_back();
}
if (next_is_entity_name) {
// The line after a " 0" group code is the entity type
counts[line]++;
next_is_entity_name = false;
}
else if (line == " 0") {
next_is_entity_name = true;
}
}
return counts;
}
//******************************************************************************
// reading

View File

@@ -61,7 +61,7 @@ public:
{
Py_XDECREF(DraftModule);
}
static std::map<std::string, int> PreScan(const std::string& filepath);
void StartImport() override;
Py::Object getStatsAsPyObject();