Through ecma scripting im able to export dwg file to svg file. while exporting the svg file is being converted in default size of inches.
example
<svg width="151.1032682882168in" height="151.1032682271798in" viewBox="-0.8053099276711326 -14.255580999176 15.11032682882168 15.11032682271798" version="1.1" xmlns="http://www.w3.org/2000/svg" style="stroke-linecap:round;stroke-linejoin:round;fill:none">
however through the qcad tool of edit ->drawing preferences-> drawing unit one can change the drawingunit to either meters or millimeters.
example
<svg width="755.516341441084mm" height="755.516341135899mm" viewBox="-805.3099276711326 -14255.580999176 15110.32682882168 15110.32682271798" version="1.1" xmlns="http://www.w3.org/2000/svg" style="stroke-linecap:round;stroke-linejoin:round;fill:none">
is there any way to to it through ecmascripting. Have set the following property through ecma scripting but it is giving the default output in inches.
properties["unit"] = "mm";
var exporter = new SvgExporter(document,properties);
How do I manage or customize the size of the svg image from inches to meters or mm
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files and screenshots.
Post one question per topic.
Re: How do I manage or customize the size of the svg image from inches to meters or mm
You can set the document unit using RDocument::setUnit, e.g.:
Code: Select all
document.setUnit(RS.Millimeter);
Re: How do I manage or customize the size of the svg image from inches to meters or mm
Thank you very much for the reply .
I have added document.setUnit(RS.Millimeter); and also properties["unit"] = RS.Millimeter; But the output file is still showing the same inches. Is there anything else which has to be added. Below is the code excerpt.
var document = new RDocument(storage, spatialIndex);
document.setUnit(RS.Millimeter);
var di = new RDocumentInterface(document);
di.importFile(inputFile);
var properties =[];
properties["unit"] = RS.Millimeter;
var exporter = new SvgExporter(document,properties);
exporter.exportFile(outputFile);
I have added document.setUnit(RS.Millimeter); and also properties["unit"] = RS.Millimeter; But the output file is still showing the same inches. Is there anything else which has to be added. Below is the code excerpt.
var document = new RDocument(storage, spatialIndex);
document.setUnit(RS.Millimeter);
var di = new RDocumentInterface(document);
di.importFile(inputFile);
var properties =[];
properties["unit"] = RS.Millimeter;
var exporter = new SvgExporter(document,properties);
exporter.exportFile(outputFile);
Re: How do I manage or customize the size of the svg image from inches to meters or mm
The drawing unit is stored in the file you are importing. So after importing a file, the document unit is set to the unit stored in the drawing file. I.e. setting the unit before the import does not have any effect at all.