Import: DXF, add dedicated import dialog

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

View File

@@ -94,6 +94,7 @@ public:
add_keyword_method("insert",
&Module::insert,
"insert(string,string) -- Insert the file into the given document.");
add_varargs_method("preScanDxf", &Module::preScanDxf, "preScanDxf(filepath) -> dict");
add_varargs_method("readDXF",
&Module::readDXF,
"readDXF(filename,[document,ignore_errors,option_source]): Imports a "
@@ -112,6 +113,26 @@ public:
}
private:
Py::Object preScanDxf(const Py::Tuple& args)
{
char* filepath_char = nullptr;
if (!PyArg_ParseTuple(args.ptr(), "et", "utf-8", &filepath_char)) {
throw Py::Exception();
}
std::string filepath(filepath_char);
PyMem_Free(filepath_char);
#include <Mod/Import/App/dxf/ImpExpDxf.h>
std::map<std::string, int> counts = Import::ImpExpDxfRead::PreScan(filepath);
Py::Dict result;
for (const auto& pair : counts) {
result.setItem(Py::String(pair.first), Py::Long(pair.second));
}
return result;
}
Py::Object importOptions(const Py::Tuple& args)
{
char* Name {};