How do I manage or customize the size of the svg image from inches to meters or mm

Use this forum to ask questions about how to do things in QCAD.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
kinoy
Junior Member
Posts: 11
Joined: Mon Mar 20, 2017 11:21 am

How do I manage or customize the size of the svg image from inches to meters or mm

Post by kinoy » Mon Apr 03, 2017 2:15 pm

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);

User avatar
andrew
Site Admin
Posts: 9061
Joined: Fri Mar 30, 2007 6:07 am

Re: How do I manage or customize the size of the svg image from inches to meters or mm

Post by andrew » Tue Apr 04, 2017 10:43 am

You can set the document unit using RDocument::setUnit, e.g.:

Code: Select all

document.setUnit(RS.Millimeter);

kinoy
Junior Member
Posts: 11
Joined: Mon Mar 20, 2017 11:21 am

Re: How do I manage or customize the size of the svg image from inches to meters or mm

Post by kinoy » Tue Apr 04, 2017 1:11 pm

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);

User avatar
andrew
Site Admin
Posts: 9061
Joined: Fri Mar 30, 2007 6:07 am

Re: How do I manage or customize the size of the svg image from inches to meters or mm

Post by andrew » Wed Apr 05, 2017 5:16 pm

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.

Post Reply

Return to “QCAD 'How Do I' Questions”