diff options
-rw-r--r-- | doc/TODO.txt | 5 | ||||
-rwxr-xr-x | scripts/publish-macosx.sh | 4 | ||||
-rw-r--r-- | src/export.cc | 53 |
3 files changed, 42 insertions, 20 deletions
diff --git a/doc/TODO.txt b/doc/TODO.txt index 63afb03..a053b58 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -169,6 +169,11 @@ o Grammar - import_*() -> *_import() (consistent prefix vs. postfix) - linear_extrude()/rotate_extrude(): Cumbersome names? -> (extrude, revolve, lathe, sweep ?) +IDEAS FOR LANGUAGE CHANGES +-------------------------- +o More strict checking of module parameters to make e.g. this fail: + module test(a,b) { a=1; b=2; echo(a,b,c); } test(c=3); + CODE ---- diff --git a/scripts/publish-macosx.sh b/scripts/publish-macosx.sh index b01d7f0..11820df 100755 --- a/scripts/publish-macosx.sh +++ b/scripts/publish-macosx.sh @@ -16,7 +16,7 @@ echo "Sanity check of the app bundle..." if [[ $? != 0 ]]; then exit 1 fi -cp OpenSCAD-$VERSION.dmg ~/Documents/Dropbox/Public -ln -sf OpenSCAD-$VERSION.dmg ~/Documents/Dropbox/Public/OpenSCAD-latest.dmg +cp OpenSCAD-$VERSION.dmg ~/Dropbox/Public +ln -sf OpenSCAD-$VERSION.dmg ~/Dropbox/Public/OpenSCAD-latest.dmg echo "Upload in progress..." diff --git a/src/export.cc b/src/export.cc index 40b16d5..2b474f6 100644 --- a/src/export.cc +++ b/src/export.cc @@ -166,6 +166,20 @@ void export_dxf(CGAL_Nef_polyhedron *root_N, QString filename, QProgressDialog * } setlocale(LC_NUMERIC, "C"); // Ensure radix is . (not ,) in output + + // Some importers (e.g. QCAD) needs a HEADER section specifying AutoCAD 2000 as + // the file format for LWPOLYLINE entities to work + fprintf(f, " 0\n" + "SECTION\n" + " 2\n" + "HEADER\n" + " 9\n" + "$ACADVER\n" + " 1\n" + "AC1015\n" + " 0\n" + "ENDSEC\n"); + // Some importers (e.g. Inkscape) needs a BLOCKS section to be present fprintf(f, " 0\n" "SECTION\n" @@ -182,26 +196,29 @@ void export_dxf(CGAL_Nef_polyhedron *root_N, QString filename, QProgressDialog * DxfData dd(*root_N); for (int i=0; i<dd.paths.size(); i++) { - for (int j=1; j<dd.paths[i].points.size(); j++) { - DxfData::Point *p1 = dd.paths[i].points[j-1]; - DxfData::Point *p2 = dd.paths[i].points[j]; - double x1 = p1->x; - double y1 = p1->y; - double x2 = p2->x; - double y2 = p2->y; - fprintf(f, " 0\n"); - fprintf(f, "LINE\n"); - // Some importers (e.g. Inkscape) needs a layer to be specified - fprintf(f, " 8\n"); - fprintf(f, "0\n"); + if (dd.paths[i].points.size() < 2) + // not a valid polygon + continue; + // Use the LWPOLYLINE class - this makes it easier to handle complete + // objects (as paths) in Inkscape. + fprintf(f, " 0\n"); + fprintf(f, "LWPOLYLINE\n"); + // Some importers (e.g. Inkscape) need a layer to be specified + fprintf(f, " 8\n"); + fprintf(f, "0\n"); + // number of vertices + fprintf(f, " 90\n"); + fprintf(f, "%d\n", dd.paths[i].points.size()); + // polygon flag (closed, ...) + fprintf(f, " 70\n"); + fprintf(f, "%d\n", dd.paths[i].is_closed ? 1 : 0); + // add all points + for (int j=0; j<dd.paths[i].points.size(); j++) { + DxfData::Point *p = dd.paths[i].points[j]; fprintf(f, " 10\n"); - fprintf(f, "%f\n", x1); - fprintf(f, " 11\n"); - fprintf(f, "%f\n", x2); + fprintf(f, "%f\n", p->x); fprintf(f, " 20\n"); - fprintf(f, "%f\n", y1); - fprintf(f, " 21\n"); - fprintf(f, "%f\n", y2); + fprintf(f, "%f\n", p->y); } } |