mirror of https://github.com/vitalif/openscad
Add SVG export via command line.
parent
f84c5acada
commit
f6129ffdb8
|
@ -217,6 +217,7 @@ int cmdline(const char *deps_output_file, const std::string &filename, Camera &c
|
|||
const char *stl_output_file = NULL;
|
||||
const char *off_output_file = NULL;
|
||||
const char *dxf_output_file = NULL;
|
||||
const char *svg_output_file = NULL;
|
||||
const char *csg_output_file = NULL;
|
||||
const char *png_output_file = NULL;
|
||||
const char *ast_output_file = NULL;
|
||||
|
@ -229,6 +230,7 @@ int cmdline(const char *deps_output_file, const std::string &filename, Camera &c
|
|||
if (suffix == ".stl") stl_output_file = output_file;
|
||||
else if (suffix == ".off") off_output_file = output_file;
|
||||
else if (suffix == ".dxf") dxf_output_file = output_file;
|
||||
else if (suffix == ".svg") svg_output_file = output_file;
|
||||
else if (suffix == ".csg") csg_output_file = output_file;
|
||||
else if (suffix == ".png") png_output_file = output_file;
|
||||
else if (suffix == ".ast") ast_output_file = output_file;
|
||||
|
@ -349,6 +351,7 @@ int cmdline(const char *deps_output_file, const std::string &filename, Camera &c
|
|||
if ( stl_output_file ) geom_out = std::string(stl_output_file);
|
||||
else if ( off_output_file ) geom_out = std::string(off_output_file);
|
||||
else if ( dxf_output_file ) geom_out = std::string(dxf_output_file);
|
||||
else if ( svg_output_file ) geom_out = std::string(svg_output_file);
|
||||
else if ( png_output_file ) geom_out = std::string(png_output_file);
|
||||
else {
|
||||
PRINTB("Output file:%s\n",output_file);
|
||||
|
@ -406,6 +409,21 @@ int cmdline(const char *deps_output_file, const std::string &filename, Camera &c
|
|||
fstream.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (svg_output_file) {
|
||||
if (root_geom->getDimension() != 2) {
|
||||
PRINT("Current top level object is not a 2D object.\n");
|
||||
return 1;
|
||||
}
|
||||
std::ofstream fstream(svg_output_file);
|
||||
if (!fstream.is_open()) {
|
||||
PRINTB("Can't open file \"%s\" for export", svg_output_file);
|
||||
}
|
||||
else {
|
||||
exportFile(root_geom.get(), fstream, OPENSCAD_SVG);
|
||||
fstream.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (png_output_file) {
|
||||
std::ofstream fstream(png_output_file,std::ios::out|std::ios::binary);
|
||||
|
|
Loading…
Reference in New Issue