2024-01-14 19:43:34 +01:00
|
|
|
include("scripts/ImportExport/SvgImporter/SvgImporter.js")
|
|
|
|
include("scripts/ImportExport/SvgImporter/SvgImporterInit.js");
|
|
|
|
include("scripts/Pro/Draw/Polyline/PolylineFromSelection/PolylineFromSelection.js");
|
|
|
|
include("scripts/Pro/Modify/Detection/Duplicates/Duplicates.js");
|
|
|
|
|
|
|
|
RFileImporterRegistry.registerFileImporter(new SvgImporterFactory());
|
|
|
|
qApp.applicationName = "SVG-DXF";
|
|
|
|
|
|
|
|
var storage = new RMemoryStorage();
|
|
|
|
var spatialIndex = new RSpatialIndexSimple();
|
|
|
|
var doc = new RDocument(storage, spatialIndex);
|
|
|
|
var di = new RDocumentInterface(doc);
|
2024-01-18 00:54:22 +01:00
|
|
|
|
2024-01-14 19:43:34 +01:00
|
|
|
var tolerance = $QCAD_TOLERANCE$;
|
2024-01-18 00:54:22 +01:00
|
|
|
var purge_duplicates = $QCAD_PURGE_DUPLICATES$;
|
|
|
|
var join_polylines = $QCAD_JOIN_POLYLINES$;
|
2024-01-14 19:43:34 +01:00
|
|
|
|
|
|
|
const importer = new SvgImporter(doc);
|
|
|
|
|
|
|
|
di.importFile("$SVG_PATH$");
|
|
|
|
|
|
|
|
if (purge_duplicates === true) {
|
|
|
|
Duplicates.findDuplicates(di, true, tolerance, 0.0, true);
|
|
|
|
var counter = doc.countSelectedEntities();
|
|
|
|
var op = new RDeleteSelectionOperation();
|
|
|
|
di.applyOperation(op);
|
|
|
|
print("Purged duplicates: " + counter);
|
|
|
|
}
|
|
|
|
|
2024-01-18 00:54:22 +01:00
|
|
|
if (join_polylines === true) {
|
|
|
|
di.selectAll();
|
|
|
|
PolylineFromSelection.autoJoinSegments(di, tolerance);
|
|
|
|
}
|
2024-01-14 19:43:34 +01:00
|
|
|
|
|
|
|
di.exportFile("$EXPORT_PATH$", "$QCAD_DXF_FORMAT$");
|
|
|
|
di.destroy();
|